我想在VB中插入一个视频,只要一运行到这个窗口时,就自动播放这个视频,该怎么做?

我想在VB中插入一个视频,只要一运行到这个窗口时,就自动播放这个视频,该怎么做?,第1张

Private Declare Function mciSendString Lib "winmmdll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub Command1_Click()
mciSendString "Close Myavi", vbNullString, 0&, 0&
mciSendString "OPEN " & AppPath & "\dawanavi ALIAS Myavi TYPE MPEGVideo", vbNullString, 0&, 0& 'AVIVideo解码器无声音,MPEGVideo缺有声音
mciSendString "Play Myavi fullscreen ", 0&, 0, 0&
End Sub
Private Sub Command2_Click()
Picture1Visible = False
mciSendString "Close Myavi", vbNullString, 0&, 0&
mciSendString "OPEN " & AppPath & "\dawanavi ALIAS Myavi TYPE MPEGVideo STYLE CHILD PARENT " & MehWnd, vbNullString, 0&, 0&
mciSendString "Play Myavi ", vbNullString, 0&, 0&
End Sub
Private Sub Command3_Click()
Picture1Visible = True
mciSendString "Close Myavi", vbNullString, 0&, 0&
mciSendString "OPEN " & AppPath & "\dawanavi ALIAS Myavi TYPE MPEGVideo STYLE CHILD PARENT " & Picture1hWnd, vbNullString, 0&, 0&
mciSendString "Play Myavi ", vbNullString, 0&, 0&
End Sub

'主窗体
Private Sub Command1_Click()‘打开添加音乐的窗体,可以用commanddialog
Form2Show
End Sub
Private Sub Command2_Click()
WindowsMediaPlayer1URL = List2List(List2ListIndex)’播放音乐
End Sub
Private Sub Command3_Click()‘暂停
If Command3Caption = "暂停播放" Then
WindowsMediaPlayer1Controlspause
Command3Caption = "继续播放"
ElseIf Command3Caption = "继续播放" Then
WindowsMediaPlayer1Controlsplay
Command3Caption = "暂停播放"
End If
End Sub
Private Sub Command4_Click()’停止
WindowsMediaPlayer1Controlsstop
End Sub
Private Sub Command5_Click()‘删除音乐
If List1ListCount > 0 Then
List1RemoveItem List1ListIndex
List2RemoveItem List2ListIndex
End If
End Sub
Private Sub Command6_Click()’列表循环播放
If Command6Caption = "列表循环" Then
Timer2Enabled = True
Command6Caption = "关闭循环"
Command7Caption = "单曲循环"
ElseIf Command6Caption = "关闭循环" Then
Command6Caption = "列表循环"
Timer2Enabled = False
End If
End Sub
Private Sub Command7_Click()‘ 单曲循环播放
If Command7Caption = "单曲循环" Then
Command7Caption = "关闭循环"
Command6Caption = "列表循环"
Timer4Enabled = True
ElseIf Command7Caption = "关闭循环" Then
Command7Caption = "单曲循环"
Timer4Enabled = False
End If
End Sub
Private Sub Command8_Click()’退出
If MsgBox("确定要退出程序吗?", 36, "请确定!") = vbYes Then
Unload Me
End If
End Sub
Private Sub Command9_Click()‘刷新
Form1Refresh
End Sub
Private Sub List1_DblClick()’双击歌曲立即播放功能
Command2_Click
End Sub
Private Sub Timer1_Timer()‘控制列表2选的歌和列表1选的歌一样
List2ListIndex = List1ListIndex
End Sub
Private Sub Timer2_Timer()’列表循环播放代码2
If WindowsMediaPlayer1playState = wmppsStopped Or WindowsMediaPlayer1playState = wmppsReady Then
If Label2Caption = Label4Caption Then
List1ListIndex = 0
List2ListIndex = 0
WindowsMediaPlayer1URL = List2List(List2ListIndex)
ElseIf WindowsMediaPlayer1playState = wmppsStopped Or WindowsMediaPlayer1playState = wmppsReady Then
If Label2Caption < Label4Caption Then
List1ListIndex = List1ListIndex + 1
List2ListIndex = List2ListIndex + 1
WindowsMediaPlayer1URL = List2List(List2ListIndex)
End If
End If
End If
End Sub
Private Sub Timer3_Timer()‘显示控制(正在播放:xx/xx)
Label2Caption = List1ListIndex + 1
Label4Caption = List1ListCount
End Sub
Private Sub Timer4_Timer()'单曲循环播放代码2
If WindowsMediaPlayer1playState = wmppsStopped Then
WindowsMediaPlayer1URL = List2List(List2ListIndex)
End If
End Sub
'添加音乐窗体
Private Sub Command1_Click()
MeHide
End Sub
Private Sub Dir1_Change()
File1Path = Dir1Path
End Sub
Private Sub Drive1_Change()
Dir1Path = Drive1Drive
End Sub
Private Sub File1_dblClick()
Form1List1AddItem File1FileName
Form1List2AddItem IIf(Len(File1Path) > 3, File1Path & "\", File1Path) & File1FileName
End Sub
MMcontrol制作的:视频教程
>

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/13111721.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-30
下一篇 2023-05-30

发表评论

登录后才能评论

评论列表(0条)

保存