Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

AVI in child control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • AVI in child control

    Code:
        #Compile Exe
        #Register None
        #Dim All
        #Include "win32Api.Inc"
        $FileAvi = "C:\WinNt\Clock.Avi" ' <--- Change
    
        CallBack Function DlgProc
           Static AVIStatus As Long
           Local rc As RECT, TmpAsciiz As Asciiz * %MAX_PATH
           %ID_OPENAVI = 102
           %ID_PLAYAVI = 103
           %ID_STOPAVI = 104
           %ID_CLOSEAVI = 105
           Select Case CbMsg
              Case %WM_INITDIALOG
                 Control Add Label,  CbHndl, 101, "", 80, 10, 110, 80, , %WS_EX_CLIENTEDGE
                 Control Add Button, CbHndl, %ID_OPENAVI, "Open", 10, 10, 50, 15
                 Control Add Button, CbHndl, %ID_PLAYAVI, "Play", 10, 30, 50, 15
                 Control Add Button, CbHndl, %ID_STOPAVI, "Stop", 10, 50, 50, 15
                 Control Add Button, CbHndl, %ID_CLOSEAVI, "Close", 10, 70, 50, 15
              Case %WM_COMMAND
                 Select Case CbCtl
                    Case %ID_OPENAVI
                       If AVIStatus <> 0 Then Beep: Exit Function
                       GetShortPathName $FileAVI, TmpAsciiz, %MAX_PATH
                       If IsFalse(mciSendString("Open " + TmpAsciiz + _
                          " type AVIVideo alias AVIFile parent" + _
                          Str$(GetDlgItem(CbHndl, 101)) + _
                          " style " + Str$(%WS_CHILD), ByVal 0, 0, ByVal 0&)) _
                          Then AVIStatus = 1 ' Opened
                       GetClientRect GetDlgItem(CbHndl, 101), rc
                       mciSendString "Put AVIFile Window At 0 0" + _
                          Str$(rc.nRight) + Str$(rc.nBottom), ByVal 0, 0, ByVal 0&
                    Case %ID_PLAYAVI
                       If AVIStatus <> 1 Then MsgBox Str$(AVIStatus): Exit Function
                       mciSendString "Play AVIFile repeat", ByVal 0, 0, ByVal 0&
                       AVIStatus = 2
                    Case %ID_STOPAVI
                     '  If AVIStatus <> 2 Then Beep: Exit Function
                       mciSendString "Stop AVIFile", ByVal 0, 0, ByVal 0&
                       AVIStatus = 1
                    Case %ID_CLOSEAVI
                       If AVIStatus = 0 Then Beep: Exit Function
                       mciSendString "Close AVIFile", ByVal 0, 0, ByVal 0&
                       AVIStatus = 0
                End Select
           End Select
        End Function
        
        Function PbMain
           Local hDlg As Long
           Dialog New 0, "PlayAvi", , , 200, 100, %WS_CAPTION Or %WS_SYSMENU To hDlg
           Dialog Show Modal hDlg Call DlgProc
        End Function

  • #2
    The same, but from resource file
    (here .rc looks so: 101 avi clock.avi)

    09.07.2002 Changed MoveMemory due to PbWIN declarations

    Code:
        ' MSDN+
    
        #Compile Exe
        #Register None
        #Dim All
        #Include "win32Api.Inc"
        $Resource "avi.Pbr"
    
        $ResourceAvi = "#101"
        $IOProcId = "MEY"
        
        Global lpData As Long
        Global fileSize As Long
    
        Function IOProc (lpMMIOInfo As MMIOINFO, _
           ByVal wMsg As Long, ByVal lParam1 As Long, ByVal lParam2 As Long) As Long
    
           Static AlreadyOpened As Long
           Select Case wMsg
              Case %MMIOM_OPEN
                 If IsFalse(alreadyOpened) Then alreadyOpened = %True: lpMMIOInfo.lDiskOffset = 0
                 Function = 0
              Case %MMIOM_CLOSE: Function = 0
              Case %MMIOM_READ:
                 MoveMemory ByVal lParam1, ByVal lpData + lpMMIOInfo.lDiskOffset, lParam2
                 lpMMIOInfo.lDiskOffset = lpMMIOInfo.lDiskOffset + lParam2
                 Function = lParam2
              Case %MMIOM_SEEK
                 Select Case lParam2
                    Case %SEEK_SET: lpMMIOInfo.lDiskOffset = lParam1
                    Case %SEEK_CUR: lpMMIOInfo.lDiskOffset = lpMMIOInfo.lDiskOffset + lParam1: _
                                    lpMMIOInfo.lDiskOffset = fileSize - 1 - lParam1
                    Case %SEEK_END: lpMMIOInfo.lDiskOffset = fileSize - 1 - lParam1
                 End Select
                 Function = lpMMIOInfo.lDiskOffset
              Case Else: Function = -1
           End Select
        End Function
    
        CallBack Function DlgProc
           Static hInst As Long, AVIStatus As Long
           Local hRsrc As Long, rc As RECT, TmpAsciiz As Asciiz * %MAX_PATH
           %ID_OPENAVI = 102
           %ID_PLAYAVI = 103
           %ID_STOPAVI = 104
           %ID_CLOSEAVI = 105
           Select Case CbMsg
              Case %WM_INITDIALOG
                 Control Add TextBox,  CbHndl, 101, "", 80, 10, 110, 80, , %WS_EX_CLIENTEDGE
                 Control Add Button, CbHndl, %ID_OPENAVI, "Open", 10, 10, 50, 15
                 Control Add Button, CbHndl, %ID_PLAYAVI, "Play", 10, 30, 50, 15
                 Control Add Button, CbHndl, %ID_STOPAVI, "Stop", 10, 50, 50, 15
                 Control Add Button, CbHndl, %ID_CLOSEAVI, "Close", 10, 70, 50, 15
                 hInst = GetModuleHandle(ByVal 0&)
              Case %WM_COMMAND
                 Select Case CbCtl
                    Case %ID_OPENAVI
                       If AVIStatus <> 0 Then Beep: Exit Function
                       hRsrc = FindResource(hInst, $ResourceAvi, "AVI") ' AVI Id
                       lpData = LockResource(LoadResource(hInst, hRsrc))
                       FileSize = SizeofResource(hInst, hRsrc)
                       mmioInstallIOProcA ByVal Cvl($IOProcId + " "), CodePtr(IOProc), _
                          %MMIO_INSTALLPROC + %MMIO_PUBLICPROC
    
                       mciSendString "Open Empty." + $IOProcId + _
                          "+ Type AVIVideo Alias AVIFILE Parent" + _
                          Str$(GetDlgItem(CbHndl, 101)) + _
                          " Style " + Str$(%WS_CHILD), ByVal 0, 0, ByVal 0&
                       AVIStatus = 1
                       GetClientRect GetDlgItem(CbHndl, 101), rc
                       mciSendString "Put AVIFile Window At 0 0" + _
                          Str$(rc.nRight) + Str$(rc.nBottom), ByVal 0, 0, ByVal 0&
                    Case %ID_PLAYAVI
                       If AVIStatus <> 1 Then Beep: Exit Function
                       mciSendString "Play AVIFile repeat", ByVal 0, 0, ByVal 0&
                       AVIStatus = 2
                    Case %ID_STOPAVI
                       If AVIStatus <> 2 Then Beep: Exit Function
                       mciSendString "Stop AVIFile", ByVal 0, 0, ByVal 0&
                       AVIStatus = 1
                    Case %ID_CLOSEAVI
                       If AVIStatus = 0 Then Beep: Exit Function
                       mciSendString "Close AVIFile", ByVal 0, 0, ByVal 0&
                       mmioInstallIOProcA ByVal Cvl($IOProcId + " "), _
                          %Null, %MMIO_REMOVEPROC
                       AVIStatus = 0
                End Select
           End Select
        End Function
    
        Function PbMain
           Local hDlg As Long
           Dialog New 0, "PlayAvi", , , 200, 100, %WS_CAPTION Or %WS_SYSMENU To hDlg
           Dialog Show Modal hDlg Call DlgProc
        End Function
    [This message has been edited by Semen Matusovski (edited July 09, 2002).]

    Comment


    • #3
      A really old thread, but let me ask a question. The example above to play an avi video works fine, but as a dialog.

      I need a short code to play an avi video straight in a window (as graphic attach HWIN,0,redraw) at a given position and given proportions, like this (not working):

      mciSendString("Open " +"e:\test.Avi" + _
      " type AVIVideo alias AVIFile parent" + _
      STR$(GetDlgItem(CBHNDL, 101)) + _
      " style " + STR$(%WS_CHILD), BYVAL 0, 0, BYVAL 0&))

      mciSendString "Put AVIFile Window At 0 0" + _
      STR$(rc.nRight) + STR$(rc.nBottom), BYVAL 0, 0, BYVAL 0&

      mciSendString "Play AVIFile repeat", BYVAL 0, 0, BYVAL 0&

      sleep 5000

      mciSendString "Stop AVIFile", BYVAL 0, 0, BYVAL 0&

      mciSendString "Close AVIFile", BYVAL 0, 0, BYVAL 0&

      Thanks for your help. I programm slot machines for my own use, and displaying win symbol animations from single pics is hard work.
      Attached Files

      Comment


      • #4
        Not an answer to your question but ...

        This kind of application is well suited for Chris Bosses' EZ GUI engine since you could use sprites to handle the animations.

        Just so you are aware.

        Kind regards
        Steven
        So here we are, this is the end.
        But all that dies, is born again.
        - From The Ashes (In This Moment)

        Comment


        • #5
          Discussion in PBWin forum here
          Rgds, Dave

          Comment

          Working...
          X