vb 打开视频
我想在vb编写的窗口中单击按钮,播放视频文件,不想用vb自带的windowsmediaplayer,想用电脑自带的播放器,不知道该怎么写代码,请高手指点。...
我想在vb编写的窗口中单击按钮,播放视频文件,不想用vb自带的windowsmedia player,想用电脑自带的播放器,不知道该怎么写代码,请高手指点。
展开
展开全部
您好!
系统自带的播放器就是windowsmediaplayer,别无它选,语法:
windowsmediaplayer1.URL="c:\视频.mp4"
或者也可以用picturebox来播放,代码:
先要点“工程”,然后“引用”,然后勾选“ActiveMovie control type library”,这样才能正常运行
Option Explicit
Private Const WS_CHILD = &H40000000
Private Const WS_CLIPCHILDREN = &H2000000
Private m_FilGraph As FilgraphManager
Private m_Video As IVideoWindow
Private Sub Command1_Click() '播放按钮
Dim strFileName As String
strFileName = "E:\电影\赤壁.rmvb" '电影的地址
Set m_FilGraph = New FilgraphManager
m_FilGraph.RenderFile strFileName
Set m_Video = m_FilGraph
With m_Video
.Owner = Picture1.hWnd 'Owner可以设置为任意窗口的句柄
.WindowStyle = WS_CHILD Or WS_CLIPCHILDREN
.Top = 0
.Left = 0
.Width = Picture1.Width / Screen.TwipsPerPixelX
.Height = Picture1.Height / Screen.TwipsPerPixelY
End With
m_FilGraph.Run
End Sub
回答完毕!
系统自带的播放器就是windowsmediaplayer,别无它选,语法:
windowsmediaplayer1.URL="c:\视频.mp4"
或者也可以用picturebox来播放,代码:
先要点“工程”,然后“引用”,然后勾选“ActiveMovie control type library”,这样才能正常运行
Option Explicit
Private Const WS_CHILD = &H40000000
Private Const WS_CLIPCHILDREN = &H2000000
Private m_FilGraph As FilgraphManager
Private m_Video As IVideoWindow
Private Sub Command1_Click() '播放按钮
Dim strFileName As String
strFileName = "E:\电影\赤壁.rmvb" '电影的地址
Set m_FilGraph = New FilgraphManager
m_FilGraph.RenderFile strFileName
Set m_Video = m_FilGraph
With m_Video
.Owner = Picture1.hWnd 'Owner可以设置为任意窗口的句柄
.WindowStyle = WS_CHILD Or WS_CLIPCHILDREN
.Top = 0
.Left = 0
.Width = Picture1.Width / Screen.TwipsPerPixelX
.Height = Picture1.Height / Screen.TwipsPerPixelY
End With
m_FilGraph.Run
End Sub
回答完毕!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询