Private Sub play_Click()
Dim s As String, ShortPathName As String
    Dim mciCommand As String
   
    
    pathname = f$
   ' If Right(pathname, 1) <> "\" Then pathname = pathname & "\"
    'pathname = pathname & File2.FileName
    
    s = String(LenB(pathname), Chr(0))
    GetShortPathName pathname, s, Len(s)
    ShortPathName = left(s, InStr(s, Chr(0)) - 1)
    
    mciSendString "close MyAVI", vbNullString, 0, 0
    
    mciCommand = "open " & ShortPathName & " alias MyAVI"
    mciCommand = mciCommand & " parent " & Picture1.hwnd & " style child"
    mciSendString mciCommand, vbNullString, 0, 0
    
    With Picture1
        .ScaleMode = vbPixels
        mciCommand = "put MyAVI window at 0 0 " & _
                     .ScaleWidth & " " & .ScaleHeight
        mciSendString mciCommand, vbNullString, 0, 0
    End With
    
    mciSendString "play MyAVI", vbNullString, 0, 0
End Sub这是一段播放视频的代码
有没有办法做个暂停的按纽
按一下暂停一下,再按一下接着播放
谢谢大家:)

解决方案 »

  1.   

    暂停就是
    mciSendString "pause MyAVI ", vbNullString, 0, 0
      

  2.   

    有没有办法做个暂停的按纽
    按一下暂停一下,再按一下接着播放
    ---
    那这个按钮事件里面,还要有个获取播放状态的语句。根据状态选择操作:Dim strStatus As String
    strStatus = String(256, Chr(0))
    mciSendString "status " & strTarget & " mode", strStatus, Len(strStatus), 0
    If Left(strStatus, 7) = "playing" Or Left(strStatus, 2) = "播放" Then
        mciSendString "pause " & strTarget, vbNullString, 0, 0
    else
        mciSendString "play " & strTarget, vbNullString, 0, 0
    end if'ps:如果文件已经关闭,则不能获取其状态。(费好大劲得出的结论!)其中的strTarget是媒体文件路径,你程序中的MyAVI 是别名,可以照上面那句改为别名的用法。