【急】用mediaplayer控件时,怎么才能收到单击界面各个按键的消息
mediaplayer控件能播放的格式太少了,但是我想用他的播放器操作界面,就是开始,停止,音量控制这些按钮,但是怎么才能收到这些按钮的单击事件??还有音量的变化事件??急用~
[解决办法]
是wmp控件吗?只要安装了解码器,都能播放。wmp的控制面板是可以隐藏的,隐藏之后,编程控制打开、播放、停止等操作。
[解决办法]
'form1的窗体代码
'在其上添加一个WMP控件
Option Explicit
'wmp播放器缩放
Private Sub Form_Resize()
WindowsMediaPlayer1.Move 0, 0, Me.Width, Me.Height
End Sub
'form1作为播放窗体
'form2作为启动窗体。播放控制。
'在Form2上添加10个命令按钮command1---command10(控件数组),1个通用对话框控件CommonDialog1
Option Explicit
Private Sub Command1_Click(Index As Integer)
'On Error Resume Next
Select Case Index
Case 0
Form1.WindowsMediaPlayer1.fullScreen = True '全屏
Case 1
Form1.WindowsMediaPlayer1.Controls.play '播放
Exit Sub
Case 2
Form1.WindowsMediaPlayer1.Controls.pause '暂停
Exit Sub
Case 3
Form1.WindowsMediaPlayer1.Controls.stop '停止
Exit Sub
Case 4
Form1.WindowsMediaPlayer1.Controls.currentPosition = Form1.WindowsMediaPlayer1.Controls.currentPosition + 100 '快进
Exit Sub
Case 5
Form1.WindowsMediaPlayer1.Controls.currentPosition = Form1.WindowsMediaPlayer1.Controls.currentPosition - 100 '快退
Exit Sub
Case 6
Form1.WindowsMediaPlayer1.Controls.Next '下一曲
Exit Sub
Case 7
Form1.WindowsMediaPlayer1.Controls.previous '上一曲
Exit Sub
Case 8
CommonDialog1.ShowOpen
Form1.WindowsMediaPlayer1.URL = CommonDialog1.FileName
Case 9
Form1.WindowsMediaPlayer1.Controls.stop
Unload Form1: Unload Form2: End
End Select
End Sub
Private Sub Form_Load()
Form1.Visible = True
Form1.WindowsMediaPlayer1.Left = 0: Form1.WindowsMediaPlayer1.Top = 0
Form1.WindowsMediaPlayer1.Width = Form1.Width: Form1.WindowsMediaPlayer1.Height = Form1.Height
Form1.WindowsMediaPlayer1.uiMode = "none" '隐藏WMP播放器控制面板
Form1.WindowsMediaPlayer1.URL = "E:\电影\月球\[月球].Moon.2009.DVDRiP.XViD-LAP.avi" '加载媒体
Form1.WindowsMediaPlayer1.stretchToFit = True
Form1.WindowsMediaPlayer1.enableContextMenu = True '允许右键菜单
Form1.WindowsMediaPlayer1.settings.autoStart = False
Form1.WindowsMediaPlayer1.windowlessVideo = False
Form1.WindowsMediaPlayer1.Controls.play
Form1.WindowsMediaPlayer1.fullScreen = False '禁止全屏
Form2.Command1(0).Caption = "全屏"
Form2.Command1(1).Caption = "播放"
Form2.Command1(2).Caption = "暂停"
Form2.Command1(3).Caption = "停止"
Form2.Command1(4).Caption = "快进"
Form2.Command1(5).Caption = "快退"
Form2.Command1(6).Caption = "下一曲"
Form2.Command1(7).Caption = "上一曲"
Form2.Command1(8).Caption = "打开"
Form2.Command1(9).Caption = "关闭"
End Sub