AxWindowsMediaPlayer控件的使用


首先要知道如何將控件添加到工具箱中,步驟如下:

  “工具箱”中單擊右鍵,選擇“選擇項”菜單,打開“選擇工具箱項”窗口,選擇“COM組件”標簽,在列表中找到並勾選“Windows Media Player”組件,單擊“確定”按鈕。將該組件添加到指定的工具箱選項卡中

 

接下來,我們需要了解axWindowsMediaPlayer 媒體主要方法屬性:

[基本屬性]   
URL:String; 指定媒體位置,本機或網絡地址
uiMode:String; 播放器界面模式,可為Full, Mini, None, Invisible
playState:integer; 播放狀態,1=停止,2=暫停,3=播放,6=正在緩沖,9=正在連接,10=准備就緒
enableContextMenu:Boolean; 啟用/禁用右鍵菜單
fullScreen:boolean; 是否全屏顯示
//播放器基本控制
Ctlcontrols.play; 播放
Ctlcontrols.pause; 暫停
Ctlcontrols.stop; 停止
Ctlcontrols.currentPosition:double; 當前進度
Ctlcontrols.currentPositionString:string; 當前進度,字符串格式。如“00:23”
Ctlcontrols.fastForward; 快進
Ctlcontrols.fastReverse; 快退
Ctlcontrols.next; 下一曲
Ctlcontrols.previous; 上一曲
[settings] wmp.settings //播放器基本設置
settings.volume:integer; 音量,0-100
settings.autoStart:Boolean; 是否自動播放
settings.mute:Boolean; 是否靜音
settings.playCount:integer; 播放次數
[currentMedia] wmp.currentMedia //當前媒體屬性
currentMedia.duration:double; 媒體總長度
currentMedia.durationString:string; 媒體總長度,字符串格式。如“03:24”
currentMedia.getItemInfo(const string); 獲取當前媒體信息"Title"=媒體標題,"Author"=藝術家,"Copyright"=版權信息,"Description"=媒體內容描述, "Duration"=持續時間(秒),"FileSize"=文件大小,"FileType"=文件類型,"sourceURL"=原始地址
currentMedia.setItemInfo(const string); 通過屬性名設置媒體信息
currentMedia.name:string; 同 currentMedia.getItemInfo("Title")
[currentPlaylist] wmp.currentPlaylist //當前播放列表屬性
currentPlaylist.count:integer; 當前播放列表所包含媒體數
currentPlaylist.Item[integer]; 獲取或設置指定項目媒體信息,其子屬性同wmp.currentMedia
axWindowsMediaPlayer1.currentMedia.sourceURL; //獲取正在播放的媒體文件的路徑
axWindowsMediaPlayer1.currentMedia.name; //獲取正在播放的媒體文件的名稱
axWindowsMediaPlayer1.Ctlcontrols.Play          播放
axWindowsMediaPlayer1.Ctlcontrols.Stop          停止
axWindowsMediaPlayer1.Ctlcontrols.Pause          暫停
axWindowsMediaPlayer1.Ctlcontrols.PlayCount        文件播放次數
axWindowsMediaPlayer1.Ctlcontrols.AutoRewind       是否循環播放
axWindowsMediaPlayer1.Ctlcontrols.Balance         聲道
axWindowsMediaPlayer1.Ctlcontrols.Volume         音量
axWindowsMediaPlayer1.Ctlcontrols.Mute          靜音
axWindowsMediaPlayer1.Ctlcontrols.EnableContextMenu    是否允許在控件上點擊鼠標右鍵時彈出快捷菜單
axWindowsMediaPlayer1.Ctlcontrols.AnimationAtStart    是否在播放前先播放動畫
axWindowsMediaPlayer1.Ctlcontrols.ShowControls      是否顯示控件工具欄
axWindowsMediaPlayer1.Ctlcontrols.ShowAudioControls    是否顯示聲音控制按鈕
axWindowsMediaPlayer1.Ctlcontrols.ShowDisplay       是否顯示數據文件的相關信息
axWindowsMediaPlayer1.Ctlcontrols.ShowGotoBar       是否顯示Goto欄
axWindowsMediaPlayer1.Ctlcontrols.ShowPositionControls  是否顯示位置調節按鈕
axWindowsMediaPlayer1.Ctlcontrols.ShowStatusBar      是否顯示狀態欄
axWindowsMediaPlayer1.Ctlcontrols.ShowTracker       是否顯示進度條
axWindowsMediaPlayer1.Ctlcontrols.FastForward       快進
axWindowsMediaPlayer1.Ctlcontrols.FastReverse       快退
axWindowsMediaPlayer1.Ctlcontrols.Rate          快進/快退速率
axWindowsMediaPlayer1.AllowChangeDisplaySize 是否允許自由設置播放圖象大小
axWindowsMediaPlayer1.DisplaySize       設置播放圖象大小
    1-MpDefaultSize         原始大小
    2-MpHalfSize           原始大小的一半
    3-MpDoubleSize          原始大小的兩倍
    4-MpFullScreen          全屏
    5-MpOneSixteenthScreen      屏幕大小的1/16
    6-MpOneFourthScreen       屏幕大小的1/4
    7-MpOneHalfScreen        屏幕大小的1/2
axWindowsMediaPlayer1.ClickToPlay       是否允許單擊播放窗口啟動Media Player
在視頻播放之后,可以通過如下方式讀取源視頻的寬度和高度,然后設置其還原為原始的大小.
private void ResizeOriginal()
{
int intWidth = axWindowsMediaPlayer1.currentMedia.imageSourceWidth;
int intHeight = axWindowsMediaPlayer1.currentMedia.imageSourceHeight;
axWindowsMediaPlayer1.Width = intWidth + 2;
axWindowsMediaPlayer1.Height = intHeight + 2;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM