Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: MCI Video Wrapper

  1. #11
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Catventure,

    I am sorry you observe issues.

    The winmm.dll is present on my Windows 10.

    MCI stands for Media Control Interface and it is a "black box" provided by Windows:
    https://docs.microsoft.com/en-us/win.../mci-reference

    mciVideo.inc is a wrapper Mike prepared 12 years ago.

    The error in playback can be caused by range of reasons - bad graphic driver, missing video codec, for example.

    I think there is also an error in the... error handling part of mciVideo.inc:
    j = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    
    The j is not declared. Please declare it as Int32/Long somewhere before the call.

    Then you should receive text error message from Microsoft, which may help you go further.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #12
    Thanks Petr, I will try your idea - but on mine no error message occurs...

    I will send it to my tester to try again and see if any error message happens.

    I have had to stop downloads of the TAB graphic versions until I can resolve this - but the text -only version can still be obtained from my site as their are no such issues with that release.

    -catventure (Phil)
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  3. #13

    Lightbulb

    Quote Originally Posted by catventure View Post
    I have had to stop downloads of the TAB graphic versions until I can resolve this
    -catventure (Phil)
    Just an idea, but you could let it available with a known bug under investigation message... for people who doesn't put videos but just pictures.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  4. #14

    Question

    Catventure, what happens if you provide your winmm.dll vista-version in the app folder (#BUNDLE File) ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  5. #15
    Quote Originally Posted by DirectuX View Post
    Just an idea, but you could let it available with a known bug under investigation message... for people who doesn't put videos but just pictures.
    Hi DirectuX,

    Yes - I will do something like that soon, I think. It's a good idea.
    There are not many users so far - so it not a biggie.
    Yes the pictures seem to load Ok - so I think can be used without videos temporarily.

    catventure.
    Last edited by catventure; 20-06-2020 at 18:11.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  6. #16
    Quote Originally Posted by DirectuX View Post
    Catventure, what happens if you provide your winmm.dll vista-version in the app folder (#BUNDLE File) ?
    Didn't think of that. Do you mean so that the dll would be bundled and be placed in the same directory as the .exe file?


    Regards,
    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  7. #17
    Quote Originally Posted by catventure View Post
    Didn't think of that. Do you mean so that the dll would be bundled and be placed in the same directory as the .exe file?


    Regards,
    catventure.
    Yes,

    but I don't know if it has to be with the exe or with thinbasic.exe

    I can try for you if you want
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  8. #18
    Quote Originally Posted by Petr Schreiber View Post
    Hi Catventure,

    The error in playback can be caused by range of reasons - bad graphic driver, missing video codec, for example.

    I think there is also an error in the... error handling part of mciVideo.inc:
    j = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    
    The j is not declared. Please declare it as Int32/Long somewhere before the call.

    Petr
    Hi Petr,

    I seem to have a later version which has already corrected the error you reported
    Instead of j it uses:
    DIM MCI_retValue as long

    ' ******************************************************
    ' * thinBasic MCI Video Playback *
    ' * by *
    ' * Michael Hartlef *
    ' * Email: contact@michaelhartlef.de *
    ' * *
    ' * Version: 1.11 (March 25th, 2007) *
    ' ******************************************************
    ' * Unofficial tweak by PSCH ( July 27th, 200 *
    ' * - msgboxes use movie window handle *
    ' * - added media repetition *
    ' * - updated IsMoviePlaying to handle repeat *
    ' ******************************************************


    ' **************************************************************************************************************************
    ' * Command set:
    ' *
    ' * n = OpenMovie(mvhWnd as long, mvfilename as string) ' Returns %TRUE if the movie could be open
    ' * CloseMovie() ' Closes a movie
    ' * PlaceMovie(xpos as long, ypos as long, width as long, height as long) ' Place and size a movie
    ' * PlayMovie(mvWait as long, mvRepeat as long) ' if mvWait is %TRUE, the app is on hold till movie is finished
    ' * ' if mvRepeat is %TRUE, then movie is played in loop
    ' * n = MovieGetLength() ' Returns the length of the movie in frames
    ' * n = MovieGetPosition() ' Returns the current position of a playing movie
    ' * n = IsMoviePlaying() ' Returns %TRUE if the movie is still playing
    ' * UpdateMovie() ' Could be used to redraw the whole frame
    ' *
    ' **************************************************************************************************************************


    uses "File"


    ' *----------------------------------------------------*
    ' * API Declarations *
    ' *----------------------------------------------------*
    DECLARE FUNCTION mciSendString LIB "WINMM.DLL" ALIAS "mciSendStringA" (byval lpstrCommand as long, BYval lpstrReturnString as long, BYVAL uReturnLength AS LONG, byval hwndCallback as long) AS LONG
    Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal fdwError As Long, byval lpszErrorText As long, ByVal cchErrorText As Long) As Long
    Declare Function GetDC Lib "user32.dll" Alias "GetDC" (ByVal hWnd As Long) As Long
    Declare Function GetShortPathName Lib "kernel32.dll" Alias "GetShortPathNameA" (ByVal lpszLongPath As long, ByVal lpszShortPath As long, ByVal cchBuffer As Long) As Long

    ' *----------------------------------------------------*
    ' * Data declarations *
    ' *----------------------------------------------------*
    dim MciMvhWnd as long = 0
    dim MciMvhdc as long = 0
    dim sMvFilename as asciiz * 257
    dim mvMciCmd as asciiz * 257
    dim mvSReturn as asciiz * 257
    dim mvi, mvj as long
    dim fileext as long
    DIM ismovie as long = %FALSE
    dim WantRepeatMovie as long
    DIM MCI_retValue AS LONG



    ' *----------------------------------------------------*
    ' * Function OpenMovie *
    ' *----------------------------------------------------*
    function OpenMovie(mvhWnd as long, mvfilename as string) as long
    fileext = iif(ucase$(FILE_PATHSPLIT(mvfilename, %Path_FileExt))="AVI", 1, 2)

    smvfilename = mvfilename
    MciMvhWnd = mvhWnd
    MciMvhdc = GetDc(mvhWnd)

    if fileext = 1 then
    mvMciCmd = "open "+chr$(34)+sMvFilename+chr$(34)+" Type AVIVideo Alias video1 "
    else
    mvMciCmd = "open "+chr$(34)+sMvFilename+chr$(34)+" Type MPEGVideo Alias video1 "
    endif

    if MciMvhWnd <> 0 then mvMciCmd = mvMciCmd + "parent"+str$(MciMvhWnd)+" Style"+Str$(&h40000000)


    mvi = mciSendString(varptr( mvMciCmd), 0,0,0)

    if mvi <> 0 then
    MCI_retValue = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    msgbox(MciMvhWnd,"Command: "+mvMciCmd+crlf+"Errorcode:"+str$(mvi)+crlf+"Errormsg: "+mvSReturn,%MB_ICONERROR, "Error->OpenMovie")
    function = %False
    else
    ismovie = %TRUE
    function = %True
    endif

    end function

    ' *----------------------------------------------------*
    ' * SUB PlaceMovie *
    ' *----------------------------------------------------*
    sub PlaceMovie(x as long, y as long, w as long, h as long)
    if ismovie = %TRUE then
    if MciMvhWnd <> 0 then
    mvMciCmd = "put video1 window at"+str$(x)+str$(y)+str$(w)+str$(h)
    mvi = mciSendString(varptr(mvMciCmd),0,0,0)
    if mvi <> 0 then
    MCI_retValue = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    msgbox(MciMvhWnd,"Command: "+mvMciCmd+crlf+"Errorcode:"+str$(mvi)+crlf+"Errormsg: "+mvSReturn,%MB_ICONERROR, "Error->PlaceMovie")
    endif
    endif
    endif
    end sub


    ' *----------------------------------------------------*
    ' * SUB CloseMovie *
    ' *----------------------------------------------------*
    Sub CloseMovie()
    if ismovie = %TRUE THEN
    mvMciCmd = "close video1"
    mvi = mciSendString(varptr(mvMciCmd),0,0,0)
    if mvi <> 0 then
    MCI_retValue = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    msgbox(MciMvhWnd,"Command: "+mvMciCmd+crlf+"Errorcode:"+str$(mvi)+crlf+"Errormsg: "+mvSReturn,%MB_ICONERROR, "Error->CloseMovie")
    endif
    ismovie = %FALSE
    ENDIF
    end sub

    ' *----------------------------------------------------*
    ' * SUB PlayMovie *
    ' *----------------------------------------------------*
    Sub PlayMovie(mvWait as long, optional mvRepeat as long = 0)
    if ismovie = %TRUE THEN


    WantRepeatMovie = iif(mvRepeat <> %FALSE, %TRUE, %FALSE)

    mvMciCmd = "play video1 "+IIF$(mvWait <> %FALSE, "wait ", "")+IIF$(mvRepeat <> %FALSE, "repeat ", "")


    mvi = mciSendString(varptr(mvMciCmd),0,0,0)
    if mvi <> 0 then
    MCI_retValue = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    msgbox(MciMvhWnd,"Command: "+mvMciCmd+crlf+"Errorcode:"+str$(mvi)+crlf+"Errormsg: "+mvSReturn,%MB_ICONERROR, "Error->PlayMovie")


    else
    if mvWait = %TRUE then CloseMovie()


    endif


    endif

    end sub




    ' *----------------------------------------------------*
    ' * Function MovieGetLength *
    ' *----------------------------------------------------*
    function MovieGetLength() as long
    if ismovie = %TRUE THEN
    mvMciCmd = "status video1 length"
    mvi = mciSendString(varptr(mvMciCmd),varptr(mvSReturn),sizeof(mvSReturn),0)
    if mvi <> 0 then
    MCI_retValue = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    msgbox(MciMvhWnd,"Command: "+mvMciCmd+crlf+"Errorcode:"+str$(mvi)+crlf+"Errormsg: "+mvSReturn, %MB_ICONERROR, "Error->MovieGetLength")
    function = -1
    else
    function = val(mvSReturn)
    endif
    else
    function = -1
    ENDIF
    end function

    ' *----------------------------------------------------*
    ' * Function MovieGetPosition *
    ' *----------------------------------------------------*
    function MovieGetPosition() as long
    if ismovie = %TRUE THEN
    mvMciCmd = "status video1 position"
    mvi = mciSendString(varptr(mvMciCmd),varptr(mvSReturn),sizeof(mvSReturn),0)
    if mvi <> 0 then
    MCI_retValue = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    msgbox(MciMvhWnd,"Command: "+mvMciCmd+crlf+"Errorcode:"+str$(mvi)+crlf+"Errormsg: "+mvSReturn,%MB_ICONERROR, "Error->MovieGetPosition")
    function = -1
    else
    function = val(mvSReturn)
    endif
    else
    function = -1
    ENDIF

    end function

    ' *----------------------------------------------------*
    ' * Function IsMoviePlaying *
    ' *----------------------------------------------------*
    function IsMoviePlaying() as long
    dim mp as long = -1
    dim ml as long = -1

    if isMovie = %True then

    if WantRepeatMovie <> %FALSE THEN return %TRUE

    mp = MovieGetPosition()
    ml = movieGetLength()


    return iif( ml <= mp, %FALSE, %TRUE )
    else
    function = %FALSE
    endif

    end function

    ' *----------------------------------------------------*
    ' * Sub UpdateMovie() *
    ' *----------------------------------------------------*
    sub UpdateMovie()
    if isMovie = %True then
    if isMoviePlaying() = %TRUE then
    mvMciCmd = "update video1 hdc "+str$(MciMvhdc)
    mvi = mciSendString(varptr(mvMciCmd),0,0,0)
    if mvi <> 0 then
    MCI_retValue = mciGetErrorString(mvi,varptr(mvSReturn),sizeof(mvSReturn))
    msgbox(MciMvhWnd,"Command: "+mvMciCmd+crlf+"Errorcode:"+str$(mvi)+crlf+"Errormsg: "+mvSReturn,%MB_ICONERROR, "Error->UpdateMovie")
    endif
    endif
    endif

    end sub

    '===================end==========

    Thanks,
    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  9. #19
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Catventure,

    I have to admit I have very limited experience with video embedding, but another idea occurred to me.

    ThinBASIC allows you to put WebBrowser control into dialog - could it be alternative way to embedd the video?

    In the meantime - error message from the user would be useful.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  10. #20
    Thanks Petr,

    I have solved the issue I had by changing my Player dialog window to using PIXELS instead of Dialog UNITS and am happy to say that the video code routine now works correctly across all Windows from XP.

    This is now closed.

    Thank you for your valuable help and suggestions.

    Best regards,
    catventure/Phil.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Another open source wrapper for FreeBASIC
    By maxim in forum Irrlicht
    Replies: 3
    Last Post: 24-06-2011, 08:03

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •