使用winsows media player控件 Option Explicit Dim MDwidth, MDheight As Integer
' 退出程序 Private Sub exit_Click(Index As Integer) End End Sub
' 初始化窗口 Private Sub Form_Load() Form1.Height = 4125 Form1.Width = 5100 MediaPlayer1.Width = 4550 MediaPlayer1.Height = 3375 CommonDialog1.Filter = "影像文件(*.Avi;*.Mpg;*.Dat;*.Asf)|*.Avi;*.MPG;*.DAT;*.Asf| All files (*.*)| *.*" End Sub
' 打开文件并自动播放 Private Sub open_Click(Index As Integer) Dim MFile As String CommonDialog1.ShowOpen MFile = CommonDialog1.FileName MediaPlayer1.FileName = MFile MediaPlayer1.AutoStart = True MediaPlayer1.AutoSize = True Form1.Width = MediaPlayer1.Width + 600 Form1.Height = MediaPlayer1.Height + 800 End Sub
' 用户改变MediaPlayer大小时,自动改变窗体大小以适应 Private Sub Timer1_Timer() If MediaPlayer1.Width <> MDwidth Or MediaPlayer1.Height <> MDheight Then Form1.Width = MediaPlayer1.Width + 600 Form1.Height = MediaPlayer1.Height + 800 MDwidth = MediaPlayer1.Width MDheight = MediaPlayer1.Height End If End Sub
利用Windows API函数实现多媒体文件得播放,可以播放MPG、AVI、MDI、WAV等文件以及文件信息
那里的源代码,很方便的,
用过Foobar吗?它就是你想要的。
Dim MDwidth, MDheight As Integer
' 退出程序
Private Sub exit_Click(Index As Integer)
End
End Sub
' 初始化窗口
Private Sub Form_Load()
Form1.Height = 4125
Form1.Width = 5100
MediaPlayer1.Width = 4550
MediaPlayer1.Height = 3375
CommonDialog1.Filter = "影像文件(*.Avi;*.Mpg;*.Dat;*.Asf)|*.Avi;*.MPG;*.DAT;*.Asf| All files (*.*)| *.*"
End Sub
' 打开文件并自动播放
Private Sub open_Click(Index As Integer)
Dim MFile As String
CommonDialog1.ShowOpen
MFile = CommonDialog1.FileName
MediaPlayer1.FileName = MFile
MediaPlayer1.AutoStart = True
MediaPlayer1.AutoSize = True
Form1.Width = MediaPlayer1.Width + 600
Form1.Height = MediaPlayer1.Height + 800
End Sub
' 用户改变MediaPlayer大小时,自动改变窗体大小以适应
Private Sub Timer1_Timer()
If MediaPlayer1.Width <> MDwidth Or MediaPlayer1.Height <> MDheight Then
Form1.Width = MediaPlayer1.Width + 600
Form1.Height = MediaPlayer1.Height + 800
MDwidth = MediaPlayer1.Width
MDheight = MediaPlayer1.Height
End If
End Sub