SOLVED - MPEG2 Play Code and Win10

Windows specific questions.
paul doe
Posts: 1314
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: SOLVED - MPEG2 Play Code and Win10

Postby paul doe » Jul 01, 2020 19:48

xbgtc wrote:...
this is getting weird!

Did you had a look at this thread?

Ways in which I can embed a video player into GFX window?
dodicat
Posts: 6720
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: SOLVED - MPEG2 Play Code and Win10

Postby dodicat » Jul 01, 2020 23:36

I have a little more control, but not enough yet.
Some info is here:
https://docs.microsoft.com/en-us/windows/win32/multimedia/playing-a-device

Code: Select all



#define WIN_INCLUDEALL
#include "Windows.bi"
#include "win/mmsystem.bi"
#include "win/vfw.bi"   'some mcisendstring constants (unused here)
#Include once "/win/commctrl.bi"
#define nul chr(0)

Dim  As MSG msg

Dim  As String req
req="Media (.mpg) files"+NUL+"*.MPG"+NUL+"Others (.mp3,.mpeg, . . .)"+NUL+"*.MP3;*.MPEG"+NUL+"All files (*.*)"+NUL+"*.*"+NUL+NUL

var Main_Win=CreateWindowEx(0,"#32770","Control",WS_OVERLAPPEDWINDOW Or WS_VISIBLE,5,5,320,550,0,0,0,0)
var starter=CreateWindowEx(0,"Button","Start", WS_VISIBLE Or WS_CHILD,0,0,60,30,Main_win,0,0,0)
var stopper=CreateWindowEx(0,"Button","Stop", WS_VISIBLE Or WS_CHILD,60,0,60,30,Main_win,0,0,0)
var player=CreateWindowEx(0,"Button","Play", WS_VISIBLE Or WS_CHILD,120,0,60,30,Main_win,0,0,0)
var finish=CreateWindowEx(0,"Button","End", WS_VISIBLE Or WS_CHILD,180,0,60,30,Main_win,0,0,0)
var message=CreateWindowEx(0,"static","", WS_VISIBLE Or WS_CHILD,10,200,260,30,Main_win,0,0,0)
var restart=CreateWindowEx(0,"button","Restart", WS_VISIBLE Or WS_CHILD,240,0,60,30,Main_win,0,0,0)
Declare Function getfiles(filetypes As String) As String
Declare Function SetWindowTheme Lib "UxTheme.dll" Alias "SetWindowTheme"(As Any Ptr,As zstring Ptr,As zstring Ptr) As Long
'freeconsole 'dont show the console box
SetWindowTheme(main_win," "," ")
 
While GetMessage( @msg,Main_Win,0,0)
    TranslateMessage(@msg)
    DispatchMessage(@msg)
    Select Case msg.hwnd
    Case Main_Win
        Select Case msg.message
        Case 273  'close by clicking X
            mciSendString("close file1", NULL, 0,0)
            End
        End Select
        '-----------------------------     
        Case starter
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            Dim As String file= getfiles(req)
        mciSendString("open  " +Chr(34)+file+Chr(34)+ " type mpegvideo alias file1", NULL, 0, 0)
        'mciSendString("window movie state show",0,0,NULL)
        var s=mid(file,1+instrrev(file,any"\\/"))
        setwindowtext(message,s)
        End Select
        '-----------------------------
        Case stopper
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("pause file1", NULL, 0,0)
        End Select
        '------------------------------
        Case player
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("play file1", NULL, 0,0)
        End Select
        '------------------------------
        Case restart
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("play file1 from 0", NULL, 0,0)
        End Select
        '------------------------------
        Case finish
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("close file1", NULL, 0,0)
        End Select
       
    End Select'(case main_win)
Wend


Sub done Destructor
    mciSendString("close file1", NULL, 0, 0)
End Sub

Function getfiles(filetypes As String) As String
    Dim As zstring * 2048 SELFILE
    Dim As String MYFILTER
    myfilter=filetypes
    Dim As OpenFileName SomeFile
    With SomeFile
        .lStructSize = Sizeof(OpenFileName)
        .hInstance = null
        .lpstrFilter = Strptr(MYFILTER)
        .lpstrFile = @SELFILE
        .nMaxFile = 2048
        .nMaxFileTitle = 0
        .lpstrTitle =@"Movies and songs"
        .Flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
    End With
    GetOpenFileName(@SomeFile)
    Return *SomeFile.lpstrFile
End Function

 
xbgtc
Posts: 211
Joined: Oct 14, 2007 5:40
Location: Australia

Re: SOLVED - MPEG2 Play Code and Win10

Postby xbgtc » Jul 02, 2020 1:20

dodicat wrote:Here are the full set of command strings for MCI
https://docs.microsoft.com/en-us/windows/win32/multimedia/mci-command-strings

Possibly a flag needed after play in play file1.

In the meantime just press escape from the console, it ends cleanly.


Thanks for the link. Before I went with Dshow I WAS using MCI but it would not play on some version of windows back in the day (was using XP myself) so ended up going to dshow which worked on XP, Vista, Win7 etc. so stuck with it :)

Haha I did press ESC but no response from program itself. I modified the code with 1 line to just Play and another to End and no probs with closing now just of course I still have no video showing in window - just audio :(
xbgtc
Posts: 211
Joined: Oct 14, 2007 5:40
Location: Australia

Re: SOLVED - MPEG2 Play Code and Win10

Postby xbgtc » Jul 02, 2020 1:21

paul doe wrote:
xbgtc wrote:...
this is getting weird!

Did you had a look at this thread?

Ways in which I can embed a video player into GFX window?


Don't think I have - will check it out thanks paul!
paul doe
Posts: 1314
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: SOLVED - MPEG2 Play Code and Win10

Postby paul doe » Jul 02, 2020 1:24

@xbgtc: No prob. I just saw it and thought you might find it useful.
xbgtc
Posts: 211
Joined: Oct 14, 2007 5:40
Location: Australia

Re: SOLVED - MPEG2 Play Code and Win10

Postby xbgtc » Jul 02, 2020 1:38

damn lost my post so i'll try again!

Thanks dodicat will see how this code goes but I think I have a codec problem on my system. I have 2 other stock standard Win10 machines so will try the Dshow code and this MCI code and see what happens but I dare say that I will need to install an mpeg codec first - we'll see :)

dodicat wrote:I have a little more control, but not enough yet.
Some info is here:
https://docs.microsoft.com/en-us/windows/win32/multimedia/playing-a-device

Code: Select all



#define WIN_INCLUDEALL
#include "Windows.bi"
#include "win/mmsystem.bi"
#include "win/vfw.bi"   'some mcisendstring constants (unused here)
#Include once "/win/commctrl.bi"
#define nul chr(0)

Dim  As MSG msg

Dim  As String req
req="Media (.mpg) files"+NUL+"*.MPG"+NUL+"Others (.mp3,.mpeg, . . .)"+NUL+"*.MP3;*.MPEG"+NUL+"All files (*.*)"+NUL+"*.*"+NUL+NUL

var Main_Win=CreateWindowEx(0,"#32770","Control",WS_OVERLAPPEDWINDOW Or WS_VISIBLE,5,5,320,550,0,0,0,0)
var starter=CreateWindowEx(0,"Button","Start", WS_VISIBLE Or WS_CHILD,0,0,60,30,Main_win,0,0,0)
var stopper=CreateWindowEx(0,"Button","Stop", WS_VISIBLE Or WS_CHILD,60,0,60,30,Main_win,0,0,0)
var player=CreateWindowEx(0,"Button","Play", WS_VISIBLE Or WS_CHILD,120,0,60,30,Main_win,0,0,0)
var finish=CreateWindowEx(0,"Button","End", WS_VISIBLE Or WS_CHILD,180,0,60,30,Main_win,0,0,0)
var message=CreateWindowEx(0,"static","", WS_VISIBLE Or WS_CHILD,10,200,260,30,Main_win,0,0,0)
var restart=CreateWindowEx(0,"button","Restart", WS_VISIBLE Or WS_CHILD,240,0,60,30,Main_win,0,0,0)
Declare Function getfiles(filetypes As String) As String
Declare Function SetWindowTheme Lib "UxTheme.dll" Alias "SetWindowTheme"(As Any Ptr,As zstring Ptr,As zstring Ptr) As Long
'freeconsole 'dont show the console box
SetWindowTheme(main_win," "," ")
 
While GetMessage( @msg,Main_Win,0,0)
    TranslateMessage(@msg)
    DispatchMessage(@msg)
    Select Case msg.hwnd
    Case Main_Win
        Select Case msg.message
        Case 273  'close by clicking X
            mciSendString("close file1", NULL, 0,0)
            End
        End Select
        '-----------------------------     
        Case starter
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            Dim As String file= getfiles(req)
        mciSendString("open  " +Chr(34)+file+Chr(34)+ " type mpegvideo alias file1", NULL, 0, 0)
        'mciSendString("window movie state show",0,0,NULL)
        var s=mid(file,1+instrrev(file,any"\\/"))
        setwindowtext(message,s)
        End Select
        '-----------------------------
        Case stopper
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("pause file1", NULL, 0,0)
        End Select
        '------------------------------
        Case player
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("play file1", NULL, 0,0)
        End Select
        '------------------------------
        Case restart
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("play file1 from 0", NULL, 0,0)
        End Select
        '------------------------------
        Case finish
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("close file1", NULL, 0,0)
        End Select
       
    End Select'(case main_win)
Wend


Sub done Destructor
    mciSendString("close file1", NULL, 0, 0)
End Sub

Function getfiles(filetypes As String) As String
    Dim As zstring * 2048 SELFILE
    Dim As String MYFILTER
    myfilter=filetypes
    Dim As OpenFileName SomeFile
    With SomeFile
        .lStructSize = Sizeof(OpenFileName)
        .hInstance = null
        .lpstrFilter = Strptr(MYFILTER)
        .lpstrFile = @SELFILE
        .nMaxFile = 2048
        .nMaxFileTitle = 0
        .lpstrTitle =@"Movies and songs"
        .Flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
    End With
    GetOpenFileName(@SomeFile)
    Return *SomeFile.lpstrFile
End Function

 
xbgtc
Posts: 211
Joined: Oct 14, 2007 5:40
Location: Australia

Re: SOLVED - MPEG2 Play Code and Win10

Postby xbgtc » Jul 02, 2020 1:53

dodicat I just tried your new code on my machine and that works fine with just a little quirk that if you click on the video window title bar after video finishes playing it says "not responding" on the title bar but if you 'end' it with the control window it closes fine so no prob really just strange why it does it.
dodicat
Posts: 6720
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: SOLVED - MPEG2 Play Code and Win10

Postby dodicat » Jul 02, 2020 8:11

I was messing around trying to get the video on to a child window some way, (or even a gfx widow), without hundred of code lines.
If I strike lucky I'll post.
Thanks for testing.
dodicat
Posts: 6720
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: SOLVED - MPEG2 Play Code and Win10

Postby dodicat » Jul 02, 2020 9:29

BINGO

Code: Select all




#define WIN_INCLUDEALL
#include "Windows.bi"
#include "win/mmsystem.bi"
#Include once "/win/commctrl.bi"
#define nul chr(0)

Dim  As MSG msg

Dim  As String req
req="Media (.mpg) files"+NUL+"*.MPG"+NUL+"Others (.mp3,.mpeg, . . .)"+NUL+"*.MP3;*.MPEG"+NUL+"All files (*.*)"+NUL+"*.*"+NUL+NUL

var Main_Win=CreateWindowEx(0,"#32770","Control",WS_OVERLAPPEDWINDOW Or WS_VISIBLE,5,5,800,600,0,0,0,0)
var starter=CreateWindowEx(0,"Button","Start", WS_VISIBLE Or WS_CHILD,0,0,60,30,Main_win,0,0,0)
var stopper=CreateWindowEx(0,"Button","Stop", WS_VISIBLE Or WS_CHILD,60,0,60,30,Main_win,0,0,0)
var player=CreateWindowEx(0,"Button","Play", WS_VISIBLE Or WS_CHILD,120,0,60,30,Main_win,0,0,0)
var finish=CreateWindowEx(0,"Button","End", WS_VISIBLE Or WS_CHILD,180,0,60,30,Main_win,0,0,0)
var message=CreateWindowEx(0,"static","", WS_VISIBLE Or WS_CHILD,500,10,200,30,Main_win,0,0,0)
var restart=CreateWindowEx(0,"button","Restart", WS_VISIBLE Or WS_CHILD,240,0,60,30,Main_win,0,0,0)
var vscreen=CreateWindowEx(0,"static","", WS_VISIBLE Or WS_CHILD or WS_BORDER,5,50,770,510,Main_win,0,0,0)
Declare Function getfiles(filetypes As String) As String
Declare Function SetWindowTheme Lib "UxTheme.dll" Alias "SetWindowTheme"(As Any Ptr,As zstring Ptr,As zstring Ptr) As Long
'freeconsole 'dont show the console box
SetWindowTheme(main_win," "," ")
 
While GetMessage( @msg,Main_Win,0,0)
    TranslateMessage(@msg)
    DispatchMessage(@msg)
    Select Case msg.hwnd
    Case Main_Win
        Select Case msg.message
        Case 273  'close by clicking X
            mciSendString("close file1", NULL, 0,0)
            End
        End Select
        '-----------------------------     
        Case starter
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            Dim As String file= getfiles(req)
        mciSendString("open  " +Chr(34)+file+Chr(34)+ " type mpegvideo alias file1", NULL, 0, 0)
        mciSendString("window file1 handle " & vscreen, 0, 0, 0)
        var s=mid(file,1+instrrev(file,any"\\/"))
        setwindowtext(message,s)
        End Select
        '-----------------------------
        Case stopper
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("pause file1", NULL, 0,0)
        End Select
        '------------------------------
        Case player
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            Dim rct As rect
                getCLIENTrect(vscreen,@rct)
                mciSendString("put file1 destination at 0 0 770 510 " , 0, 0, 0)
            mciSendString("play file1", NULL, 0,0)
        End Select
        '------------------------------
        Case restart
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("play file1 from 0", NULL, 0,0)
        End Select
        '------------------------------
        Case finish
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("close file1", NULL, 0,0)
        End Select
       
    End Select'(case main_win)
Wend


Sub done Destructor
    mciSendString("close file1", NULL, 0, 0)
End Sub

Function getfiles(filetypes As String) As String
    Dim As zstring * 2048 SELFILE
    Dim As String MYFILTER
    myfilter=filetypes
    Dim As OpenFileName SomeFile
    With SomeFile
        .lStructSize = Sizeof(OpenFileName)
        .hInstance = null
        .lpstrFilter = Strptr(MYFILTER)
        .lpstrFile = @SELFILE
        .nMaxFile = 2048
        .nMaxFileTitle = 0
        .lpstrTitle =@"Movies and songs"
        .Flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
    End With
    GetOpenFileName(@SomeFile)
    Return *SomeFile.lpstrFile
End Function


 

For things like fast forward e.t.c. you can make your own buttons and refer to
https://docs.microsoft.com/en-us/windows/win32/multimedia/mci-command-strings
xbgtc
Posts: 211
Joined: Oct 14, 2007 5:40
Location: Australia

Re: SOLVED - MPEG2 Play Code and Win10

Postby xbgtc » Jul 02, 2020 11:18

I just played this code and it worked! Well done dodicat :)
Just one thing though: Can the vid be positioned and reduced in size too? ie. have it play say 1/4 the size and centred In the screen? This is all I really need to be able to do (what my original dshow code does).

Now let me explain what is happening my end and why I was so surprised this code worked.

As mentioned last post I wanted to test the code on the other win10 machine so i compiled my dshow code, your previous MCI code and just the below 6 lines of code.

Code: Select all

#include "Windows.bi"
#include "win/mmsystem.bi"
mciSendString("open  videol.mpg",NULL,0,0)
mciSendString("play video.mpg",NULL,0,0)
sleep 5000
mciSendString("close video.mpg",NULL,0,0)

then went to the other win10 machine and ran all three and none of them showed video. this proved that I need a codec. I was surprised that the MCI code didn't work as that doesn't use dshow?

Anyway, on my machine I had been uninstalling and re-installing that K-Lite Codec Pack (just installing a mpeg video codec and nothing else) but still I get only audio when playing the code from within FBIde.

After uninstalling again I thought i'd install the codecs to a different directory this time. Then I tried running the compiled code and yep all three now worked! I thought that installing codecs to a new directory was what fixed it but to my surprise when I ran all 3 in FBIde they did not work (just audio again) BUT this new code you wrote here worked in FBIde and why I was surprised. I just don't get why all this is happening :)

PS: thanks for that link - lots of commands! :)

dodicat wrote:BINGO

Code: Select all




#define WIN_INCLUDEALL
#include "Windows.bi"
#include "win/mmsystem.bi"
#Include once "/win/commctrl.bi"
#define nul chr(0)

Dim  As MSG msg

Dim  As String req
req="Media (.mpg) files"+NUL+"*.MPG"+NUL+"Others (.mp3,.mpeg, . . .)"+NUL+"*.MP3;*.MPEG"+NUL+"All files (*.*)"+NUL+"*.*"+NUL+NUL

var Main_Win=CreateWindowEx(0,"#32770","Control",WS_OVERLAPPEDWINDOW Or WS_VISIBLE,5,5,800,600,0,0,0,0)
var starter=CreateWindowEx(0,"Button","Start", WS_VISIBLE Or WS_CHILD,0,0,60,30,Main_win,0,0,0)
var stopper=CreateWindowEx(0,"Button","Stop", WS_VISIBLE Or WS_CHILD,60,0,60,30,Main_win,0,0,0)
var player=CreateWindowEx(0,"Button","Play", WS_VISIBLE Or WS_CHILD,120,0,60,30,Main_win,0,0,0)
var finish=CreateWindowEx(0,"Button","End", WS_VISIBLE Or WS_CHILD,180,0,60,30,Main_win,0,0,0)
var message=CreateWindowEx(0,"static","", WS_VISIBLE Or WS_CHILD,500,10,200,30,Main_win,0,0,0)
var restart=CreateWindowEx(0,"button","Restart", WS_VISIBLE Or WS_CHILD,240,0,60,30,Main_win,0,0,0)
var vscreen=CreateWindowEx(0,"static","", WS_VISIBLE Or WS_CHILD or WS_BORDER,5,50,770,510,Main_win,0,0,0)
Declare Function getfiles(filetypes As String) As String
Declare Function SetWindowTheme Lib "UxTheme.dll" Alias "SetWindowTheme"(As Any Ptr,As zstring Ptr,As zstring Ptr) As Long
'freeconsole 'dont show the console box
SetWindowTheme(main_win," "," ")
 
While GetMessage( @msg,Main_Win,0,0)
    TranslateMessage(@msg)
    DispatchMessage(@msg)
    Select Case msg.hwnd
    Case Main_Win
        Select Case msg.message
        Case 273  'close by clicking X
            mciSendString("close file1", NULL, 0,0)
            End
        End Select
        '-----------------------------     
        Case starter
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            Dim As String file= getfiles(req)
        mciSendString("open  " +Chr(34)+file+Chr(34)+ " type mpegvideo alias file1", NULL, 0, 0)
        mciSendString("window file1 handle " & vscreen, 0, 0, 0)
        var s=mid(file,1+instrrev(file,any"\\/"))
        setwindowtext(message,s)
        End Select
        '-----------------------------
        Case stopper
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("pause file1", NULL, 0,0)
        End Select
        '------------------------------
        Case player
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            Dim rct As rect
                getCLIENTrect(vscreen,@rct)
                mciSendString("put file1 destination at 0 0 770 510 " , 0, 0, 0)
            mciSendString("play file1", NULL, 0,0)
        End Select
        '------------------------------
        Case restart
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("play file1 from 0", NULL, 0,0)
        End Select
        '------------------------------
        Case finish
        Select Case msg.message 
        Case WM_LBUTTONDOWN
            mciSendString("close file1", NULL, 0,0)
        End Select
       
    End Select'(case main_win)
Wend


Sub done Destructor
    mciSendString("close file1", NULL, 0, 0)
End Sub

Function getfiles(filetypes As String) As String
    Dim As zstring * 2048 SELFILE
    Dim As String MYFILTER
    myfilter=filetypes
    Dim As OpenFileName SomeFile
    With SomeFile
        .lStructSize = Sizeof(OpenFileName)
        .hInstance = null
        .lpstrFilter = Strptr(MYFILTER)
        .lpstrFile = @SELFILE
        .nMaxFile = 2048
        .nMaxFileTitle = 0
        .lpstrTitle =@"Movies and songs"
        .Flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
    End With
    GetOpenFileName(@SomeFile)
    Return *SomeFile.lpstrFile
End Function


 

For things like fast forward e.t.c. you can make your own buttons and refer to
https://docs.microsoft.com/en-us/windows/win32/multimedia/mci-command-strings
dodicat
Posts: 6720
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: SOLVED - MPEG2 Play Code and Win10

Postby dodicat » Jul 02, 2020 12:27

line ~~ 60
you could use
mciSendString("put file1 destination at 130 100 500 300 " , 0, 0, 0)
which places the video near the centre and reduces the size.
You can alter the sizes of all windows in the createwindowex of course.
As per usual with win api you have to fiddle around a little to get what you want.
But I am pleased you have it running in fbide (my ide also)
xbgtc
Posts: 211
Joined: Oct 14, 2007 5:40
Location: Australia

Re: SOLVED - MPEG2 Play Code and Win10

Postby xbgtc » Jul 02, 2020 15:02

Would you believe that Now not even this code shows video?
I don't know what the hell is going on but it worked when I first tried it but now it's gone like all the others and audio only - sheesh!

Should of picked up that positioning and sizing but thanks for that and after changing it and compiling it worked as expected so that's all good :)

So now have to figure out why all these vid programs work initially then fail.. but when compiled they work fine.. must be something happening!
xbgtc
Posts: 211
Joined: Oct 14, 2007 5:40
Location: Australia

Re: SOLVED - MPEG2 Play Code and Win10

Postby xbgtc » Jul 03, 2020 5:19

dodicat - how do you know when the video has finished playing? I've been trying to work it out but getting nowhere. I've used the notify command eg.

mciSendString ("play file1 notify", NULL, 0,0)

but can't work out how to find out when plays ended. It's supposed to return zero on completion I think but it's always zero while playing so hmm :)
dodicat
Posts: 6720
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: SOLVED - MPEG2 Play Code and Win10

Postby dodicat » Jul 03, 2020 12:48

I'll investigate that.
It has something to do with

status file1 file completion

Anyway, here is the video on a gfx screen.
(actually an opengl screen, which is not strictly gfx)

Code: Select all

 


#define WIN_INCLUDEALL
#include "Windows.bi"
#include "win/mmsystem.bi"
#Include once "/win/commctrl.bi"
#include "crt.bi"


sub play(file as string,p as any ptr)
  dim as integer x,y
  screeninfo x,y
  windowtitle file+ "       p = pause, r = resume, s = restart, q = quit"
  mciSendString("open  " +Chr(34)+file+Chr(34)+ " type mpegvideo alias file1", NULL, 0, 0)
  mciSendString("window file1 handle " & p, 0, 0, 0)
  mciSendString("put file1 destination at 0 0 "+ str(x)+" "+ str(y)+" " , 0, 0, 0)
  mciSendString("play file1", NULL, 0,0)
 
  dim as string key
  do
    key=inkey
    select case key
    case "p"
      mciSendString("pause file1", NULL, 0,0)
     case "r"
       mciSendString("play file1", NULL, 0,0)
     case "s"
        mciSendString("play file1 from 0", NULL, 0,0)
    case "q"
        mciSendString("close file1", NULL, 0, 0):end
    end select
  flip
  if key=chr(27) then mciSendString("close file1", NULL, 0, 0):end
  sleep 1
 loop
end sub

function gethandle as any ptr 
static as any ptr win
screencontrol 2,*cast(integer ptr,@win)
return win
end function

Sub done Destructor
    mciSendString("close file1", NULL, 0, 0)
End Sub


screen 20,,,2
play("orbiter.mpg",gethandle)


 

Just put in the path of your video file (No spaces in names, I read that mciSendString can't handle spaces)
xbgtc
Posts: 211
Joined: Oct 14, 2007 5:40
Location: Australia

Re: SOLVED - MPEG2 Play Code and Win10

Postby xbgtc » Jul 03, 2020 14:29

thanks dodicat appreciated as i'm still looking trying to work it out but way too hard for me. I found this C++ code (link below) but just don't understand it :)

https://www.codeproject.com/articles/17 ... edia-files

It's funny that you are doing the FBGX screen as that's what I am doing too! My code so far:

Code: Select all

#define WIN_INCLUDEALL
#include "Windows.bi"
#include "win/mmsystem.bi"
#Include once "/win/commctrl.bi"
#define nul chr(0)
screencontrol(103,"GDI")
screenres 800,600,32
dim shared HWND as hwnd
screencontrol(2,cast(integer,hwnd))
mciSendString("open  " +Chr(34)+"lesgrl.mpg"+Chr(34)+ " type mpegvideo alias file1", NULL, 0, 0)
mciSendString("window file1 handle " & hwnd, 0, 0, 0)
'mciSendString("pause file1", NULL, 0,0)
mciSendString("put file1 destination at 320 320 160 120 " , 0, 0, 0)
mciSendString("play file1 notify", NULL, 0, HWND)
sleep 3000
mciSendString("close file1", NULL, 0,0)

I've run your code and that works well (only i can't see it) :)

I've re-installed WinFBE_Suite and when the programs ran they all show video ok - bloody weird!

I got the 'test.bas' in C:\FreeBASICHacker\examples\win32\COM\MoviePlayer\ working by building the lib (never knew you had to do this!) and the program displays the video fine in FBIde so why this is ok and the others are not is mystifying.

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests