Position AVI video file with MCI

Windows specific questions.
Post Reply
geminis4941
Posts: 64
Joined: Jul 15, 2009 12:41

Position AVI video file with MCI

Post by geminis4941 »

Hello. I created a child window for displaying a video file with MCI. The code is basically bellow . The problem is that the video shows in top left corner of the child window and in a small size. Can anybody help me with the "put myvid destination" command if
it cause the problem?. How can i fill the child window with video?
Thanks in advanced.

Code: Select all

    #Include Once "windows.bi"
    #Include Once "win/mmsystem.bi"

    ' Change this to video file path:
    #Define VIDEO_FILE1 "c:\videos\video6.mpg"
    #Define VIDEO_FILE2 "c:\videos\video2.avi"
    #Define VIDEO_FILE3 "c:\videos\video1.avi"
    #Define VIDEO_FILE4 "c:\videos\video4.mp4"
    

    Dim Shared As HINSTANCE hInst
        hInst = GetModuleHandle(NULL)

    Dim Shared As HWND video, overlay

    Function WndProc(hWnd As HWND, msg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
        Select Case msg
            Case WM_CREATE
                video = CreateWindowEx(NULL, "Static", "", WS_CHILD OR WS_VISIBLE OR SS_USERITEM, _
                                                                    100, 100, 600, 400, hWnd, 0, hInst, 0)

          
                mciSendString("open """ & VIDEO_FILE3 & """ type MPEGVideo Alias myvid", 0, 0, 0)
                mciSendString("window myvid handle " & video, 0, 0, 0)
                Dim rcmovie As rect 
                getCLIENTrect(video,@rcmovie)
                mciSendString("put myvid destination at 0 0 700 500 " , 0, 0, 0)
                mciSendString("play myvid", 0, 0, 0)
                'mciSendString("play myvid fullscreen", lpszReturnString,lstrlen(lpszReturnString), NULL);
                'mciSendString("play myvid fullscreen", 0,0,0)
                
                Dim As ZString*256 ret
                mciSendString("status myvid frame rate", ret, 256, 0)                

            Case WM_DESTROY
                'DeleteObject(hf)
                PostQuitMessage(NULL)
        End Select
        Return DefWindowProc(hWnd, msg, wParam, lParam)
    End Function

    Dim As MSG          uMsg
    Dim As WNDCLASS     wcls
    Dim As HWND         hWnd

    With wcls
       .style           = CS_HREDRAW Or CS_VREDRAW
       .lpfnWndProc     = Cast(WNDPROC, @WndProc)
       .hInstance       = hInst
       .hIcon           = LoadIcon(NULL, IDI_APPLICATION)
       .hCursor         = LoadCursor(NULL, IDC_ARROW)
       .hbrBackground   = GetStockObject(WHITE_BRUSH)
       .lpszMenuName    = NULL
       .lpszClassName   = StrPtr("WindowClass")
    End With

    If RegisterClass(@wcls) = FALSE Then
       MessageBox(NULL, "RegisterClass(@wcls) FAIL!", "Error!", MB_OK Or MB_ICONERROR)
       End
    EndIf

    hWnd = CreateWindowEx(0,WCls.lpszClassName, "Window",  WS_POPUP Or WS_VISIBLE Or _
             WS_CLIPCHILDREN Or WS_CLIPSIBLINGS, 10, 10, 1000, 800, NULL, NULL, hInst, NULL)

    ShowWindow(hWnd, SW_NORMAL)
    UpdateWindow(hWnd)

    While GetMessage(@uMsg, NULL, NULL, NULL) <> FALSE
       TranslateMessage(@uMsg)
       DispatchMessage(@uMsg)
    Wend

  
chung
Posts: 648
Joined: Jan 16, 2010 20:52
Location: France
Contact:

Re: Position AVI video file with MCI

Post by chung »

heres an example with gui_chung

Code: Select all

#Include once "gui_chung.bi"
#include Once "win/mmsystem.bi"

Dim Shared As Integer quit
Sub mysubquit
	quit=1
End Sub
Sub playvideo()
Var fic=exepath+"/media/seashore.avi"	
mciSendString("open """ & fic & """ type MPEGVideo Alias myvid", 0, 0, 0)
mciSendString("window myvid handle " +str(getguih("win.graph")), 0, 0, 0)
mciSendString("put myvid destination", 0, 0, 0)
mciSendString("setaudio myvid volume to 400", 0, 0, 0)
mciSendString("play myvid from 0 repeat", 0, 0, 0)	
End Sub

graphicbox("win.graph",2,2,390,180)
openwindow("win","video_test",100,50,400,210)

trapclose("win",@mysubquit)
playvideo()

While guitestkey(vk_ESCAPE)=0 and quit=0
	Sleep 100
	guiscan
Wend

mciSendString("close myvid", 0, 0, 0)
guiclosewindow("win")
Sleep 1000

guiclose()
guiquit()

End 
Post Reply