Win10 and DSHOW

Windows specific questions.
xbgtc
Posts: 157
Joined: Oct 14, 2007 5:40
Location: Australia

Win10 and DSHOW

Postby xbgtc » Jan 16, 2019 0:19

Well, bummer that my video playing code does not work in Win10 Pro (ver. 10.0.17134) and I think it's because they've dropped directshow somewhere along the way so question is:

What do you use to play video in FreeBasic now?

I've tried the example program in Freebasic x64 (test.bas) and that just errors with:

Command executed:
"C:\Users\Franco\FreeBASIC64\fbc.exe" "C:\Users\Franco\FreeBASIC64\examples\win32\COM\MoviePlayer\FBIDETEMP.bas"

Compiler output:
C:\Users\Franco\FreeBASIC64\examples\win32\COM\MoviePlayer\FBIDETEMP.bas(141) error 41: Variable not declared, GWL_HINSTANCE in 'cast( HINSTANCE, GetWindowLong( parent, GWL_HINSTANCE ) ), _'
C:\Users\Franco\FreeBASIC64\examples\win32\COM\MoviePlayer\FBIDETEMP.bas(288) warning 3(1): Passing different pointer types, at parameter 2 (filename) of MOVIE_ONCREATE()

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win64 (64bit)
OS: Windows NT 6.2 (build 9200)

and the code below (that used to run in XP and Win7) just produces an empty window now with any version of FreeBasic.

Code: Select all

#include once "win/dshow.bi"
screencontrol(103,"GDI")
screenres 800,600,32
declare sub playvid(param as any ptr)
dim shared as string vid
dim shared as integer terminate,flag,t=48
dim shared HWND as hwnd
screencontrol(2,cast(integer,hwnd))
dim shared as any ptr thread,p
thread=threadcreate(@playvid,0)
sleep 100
'p=imagecreate(160,120)
vid="lesgrl.dat" 'plays file in the basic program's dir
sleep 2000
do
    t+=1
    locate t,50
    ?"yeah!!";
    flag=1
    sleep 50
    flag=0
    sleep
loop while inkey<>chr(27)
terminate=1
threadwait(thread)
'imagedestroy(p)
sub playvid(param as any ptr)
    dim as any ptr evCode,param1,param2
    dim as uinteger sh,sw,hor,ver,wid,hei,fag,pevc,pp1,pp2,vidon
    sw=800
    sh=600
    evCode=@pevc
    param1=@pp1
    param2=@pp2
    if sh<601 then
        hor=sw/2-80
        wid=160
        hei=120
    else
        hor=sw/2-160
        wid=320
        hei=240
    end if
    ver=sh/2+92
    vid="dummy" 'needed else exits with error if ESC before vid plays
    dim as IGraphBuilder Ptr pGraph
    dim as IMediaEvent   Ptr pEvent
    dim as IMediaControl Ptr pControl
    dim as IVideoWindow  Ptr vidwindow
    while (1)
        do
            if terminate then
                IMediaControl_Stop(pControl)
                IBasicVideo_Release(pEvent)
                IBasicVideo_Release(pControl)
                IBasicVideo_Release(pGraph)
                IBasicVideo_Release(vidwindow)
                CoUninitialize()
                exit sub
            end if
            if fag=1 then
                sleep_ 50
                IMediaEvent_GetEvent(pEvent,evCode,param1,param2,0)
                if pevc=1 then 'if vid has ended
                    line(hor-2,ver-2)-(hor+wid+2,ver+hei+2),&h000000,bf 'line(350,474)-(674,718),&h000000,bf
                    vidon=0
                    fag=2 'so only calls IMediaEvent after a vid is played
                end if
                if flag then 'for when you blank it out with text
                    IVideoWindow_put_visible(vidwindow,oafalse)
                    IVideoWindow_put_visible(vidwindow,oatrue)
                end if
            end if
            sleep_ 50
        loop while vid=""
        vidon=1
        if fag then
            line(hor-2,ver-2)-(hor+wid+2,ver+hei+2),&hc0c0c0,b
            line(hor-1,ver-1)-(hor+wid+1,ver+hei+1),&hc0c0c0,b
            IMediaControl_Stop(pControl)
            IBasicVideo_Release(pEvent)
            IBasicVideo_Release(pControl)
            IBasicVideo_Release(pGraph)
            IBasicVideo_Release(vidwindow)
            CoUninitialize()
        end if
        if fag then
            dim as IGraphBuilder Ptr pGraph
            dim as IMediaEvent   Ptr pEvent
            dim as IMediaControl Ptr pControl
            dim as IVideoWindow  Ptr vidwindow
        end if
        dim pasta as any ptr
        dim msg as integer
        pasta=@msg
        Var hr=CoInitialize(0)
        hr=CoCreateInstance(@CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,@IID_IGraphBuilder,@pGraph)
        hr=IGraphBuilder_QueryInterface(pGraph,@IID_IMediaEvent,@pEvent)
        hr=IGraphBuilder_QueryInterface(pGraph,@IID_IMediaControl,@pControl)
        hr=IGraphBuilder_QueryInterface(pGraph,@IID_IVideoWindow,@vidwindow)
        IGraphBuilder_RenderFile(pGraph,vid,NULL)
        'IVideoWindow_put_FullScreenMode(vidwindow,oatrue) 'puts in fullscreen mode
        IVideoWindow_put_Owner(vidwindow,cast(integer,hwnd))
        'take this next line out then it draws in your screen but in window (full screen only)
        IVideoWindow_put_WindowStyle(vidwindow,WS_CHILD or WS_CLIPSIBLINGS or WS_CLIPCHILDREN)
        IVideoWindow_SetWindowPosition(vidwindow,cast(uinteger,hor),cast(uinteger,ver),cast(uinteger,wid),cast(uinteger,hei))
        IMediaControl_Run(pControl)
        vid=""
        'IMediaEvent_WaitForCompletion(pEvent,-1,pasta)
        fag=1
    wend
end sub

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests