《WF播放器属性.doc》由会员分享,可在线阅读,更多相关《WF播放器属性.doc(8页珍藏版)》请在金锄头文库上搜索。
1、AxWindowsMediaPlayer媒体文件主要方法属性属性/方法名: 说明: 基本属性 URL:String; 指定媒体位置,本机或网络地址 uiMode:String; 播放器界面模式,可为Full, Mini, None, Invisible playState: WMPPlayState; 播放状态,wmppsStopped =停止,wmppsPaused =暂停,wmppsPlaying =播放enableContextMenu:Boolean; 启用/禁用右键菜单 fullScreen:boolean; 是否全屏显示 / Ctlcontrols播放器基本控制 Ctlcontro
2、ls.play(); 播放 Ctlcontrols.pause; 暂停 Ctlcontrols.stop; 停止 Ctlcontrols.currentPosition:double; 当前进度 Ctlcontrols.currentPositionString:string; 当前进度,字符串格式。如“00:23” Ctlcontrols.fastForward; 快进 Ctlcontrols.fastReverse; 快退 Ctlcontrols.next; 下一曲 Ctlcontrols.previous; 上一曲 settings wmp.settings /播放器基本设置 setti
3、ngs.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); 获取当前
4、媒体信息Title=媒体标题,Author=艺术家,Copyright=版权信息,Description=媒体内容描述, Duration=持续时间(秒),FileSize=文件大小,FileType=文件类型,sourceURL=原始地址 currentMedia.setItemInfo(const string); 通过属性名设置媒体信息 currentMedia.name:string; 同 currentMedia.getItemInfo(Title) currentPlaylist wmp.currentPlaylist /当前播放列表属性 currentPlaylist.count
5、:integer; 当前播放列表所包含媒体数 currentPlaylist.Iteminteger; 获取或设置指定项目媒体信息,其子属性同-wmp.currentMedia axWindowsMediaPlayer1.currentMedia.sourceURL; /获取正在播放的媒体文件的路径axWindowsMediaPlayer1.currentMedia.name; /获取正在播放的媒体文件的名称axWindowsMediaPlayer1.Ctlcontrols.Play()播放axWindowsMediaPlayer1.Ctlcontrols.Stop停止axWindowsMed
6、iaPlayer1.Ctlcontrols.Pause 暂停axWindowsMediaPlayer1.Ctlcontrols.PlayCount文件播放次数axWindowsMediaPlayer1.Ctlcontrols.AutoRewind是否循环播放axWindowsMediaPlayer1.Ctlcontrols.Balance声道axWindowsMediaPlayer1.Ctlcontrols.Volume音量axWindowsMediaPlayer1.Ctlcontrols.Mute静音axWindowsMediaPlayer1.Ctlcontrols.EnableContex
7、tMenu是否允许在控件上点击鼠标右键时弹出快捷菜单axWindowsMediaPlayer1.Ctlcontrols.AnimationAtStart是否在播放前先播放动画axWindowsMediaPlayer1.Ctlcontrols.ShowControls是否显示控件工具栏axWindowsMediaPlayer1.Ctlcontrols.ShowAudioControls是否显示声音控制按钮axWindowsMediaPlayer1.Ctlcontrols.ShowDisplay是否显示数据文件的相关信息axWindowsMediaPlayer1.Ctlcontrols.ShowG
8、otoBar是否显示Goto栏axWindowsMediaPlayer1.Ctlcontrols.ShowPositionControls是否显示位置调节按钮axWindowsMediaPlayer1.Ctlcontrols.ShowStatusBar是否显示状态栏axWindowsMediaPlayer1.Ctlcontrols.ShowTracker是否显示进度条axWindowsMediaPlayer1.Ctlcontrols.FastForward快进axWindowsMediaPlayer1.Ctlcontrols.FastReverse快退axWindowsMediaPlayer1
9、.Ctlcontrols.Rate快进快退速率axWindowsMediaPlayer1.AllowChangeDisplaySize是否允许自由设置播放图象大小axWindowsMediaPlayer1.DisplaySize设置播放图象大小1-MpDefaultSize原始大小2-MpHalfSize 原始大小的一半3-MpDoubleSize 原始大小的两倍4-MpFullScreen 全屏5-MpOneSixteenthScreen 屏幕大小的1/166-MpOneFourthScreen屏幕大小的1/47-MpOneHalfScreen屏幕大小的1/2axWindowsMediaPl
10、ayer1.ClickToPlay是否允许单击播放窗口启动Media Player在视频播放之后,可以通过如下方式读取源视频的宽度和高度,然后设置其还原为原始的大小. private void ResizeOriginal() int intWidth = axWindowsMediaPlayer1.currentMedia.imageSourceWidth; int intHeight = axWindowsMediaPlayer1.currentMedia.imageSourceHeight; axWindowsMediaPlayer1.Width = intWidth + 2; axWi
11、ndowsMediaPlayer1.Height = intHeight + 2; 打开媒体文件并播放: Dim filePath As String With Me.OpenFileDialog1 .Title = 打开语音文件 .CheckPathExists = True .CheckFileExists = True .Multiselect = False .Filter = mp3文件(*.mp3)|*.mp3|所有文件(*.*)|*.* If .ShowDialog = DialogResult.Cancel Then Exit Sub End If filePath = .Fi
12、leName End With Me.Text = PC复读机-文件 & filePath AxWindowsMediaPlayer1.URL = filePath Try Me.AxWindowsMediaPlayer1.Ctlcontrols.play() Catch ex As Exception MsgBox(对不起,不能播放此格式语音文件, MsgBoxStyle.OKOnly, PC复读机) Exit Sub End Try注意:AxWindowsMediaPlayer1.URL 中URL是表示要播放的文件名, 取消了原来的Name属性.AxWindowsMediaPlayer1.
13、Ctlcontrols.play()播放,同样还有Pause, Stop等其他属性.AxWindowsMediaPlayer1.settings.balance表示媒体播放的声道设置, 0表示均衡,-1和1表示左右声道.AxWindowsMediaPlayer1.currentMedia.duration 表示要播放的文件的时间长度.可用它获取文件长度.AxWindowsMediaPlayer1.Ctlcontrols.currentPosition表示正在播放的文件的当前播放位置,可用这个属性来对媒体文件进行前进后退等设置.如AxWindowsMediaPlayer1.Ctlcontrols.currentPosition+1 表示前进1个时间单位.AxWindowsMediaPlayer1.settings.rate播放速率,一般乘以16后再显示kbps单位.注意:在上面程序中,如果在后面加上一个:msgbox(AxWindowsMediaPlayer1.currentMedia.duration.ToString )则