Play a video on a PanelGadget?

Just starting out? Need help? Post your questions and find answers here.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Play a video on a PanelGadget?

Post by RASHAD »

Back to square one
PB want the movie played in tab 2 (by clicking)
so here tip #1 using *netmaestro* Procedure
Tab index start with 0

Code: Select all

Global ypos,movh

ProcedureDLL.l GetPanelItemhWnd(gadget, Item); Return the WindowID of a Panel-Item
  tc_item.TC_ITEM
  tc_item\mask=#TCIF_PARAM
  SendMessage_(GadgetID(Gadget),#TCM_GETITEM,Item,tc_item)
  ProcedureReturn tc_item\lparam
EndProcedure

InitMovie()

OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget(1,5,5,390,290)

AddGadgetItem(1,-1,"1")
AddGadgetItem(1,-1,"2")
AddGadgetItem(1,-1,"3")
CloseGadgetList()

LoadMovie(0,"e:\wanted.avi")
ypos = (265-(MovieHeight(0)*384/MovieWidth(0)))/2
movh = MovieHeight(0)*384/MovieWidth(0)
SetGadgetState(1,0)

Repeat
 Event = WaitWindowEvent()
    If Event=#PB_Event_Gadget 
        Num =GetGadgetState(1) 
        Result$ = GetGadgetItemText(1, Num,0)
        If Result$ = "2"
            If Movieflag = 0
                PlayMovie(0,GetPanelItemhWnd(1,1))
                ResizeMovie(0,0,ypos,384,movh)
            Else
                ResumeMovie(0)
            EndIf 
        Else
            If MovieStatus(0) > 0
               PauseMovie(0)
               Movieflag = 1
            EndIf
        EndIf
    EndIf
Until Event = #PB_Event_CloseWindow
FreeMovie(0)
Or fool with z-order
Tip #2

Code: Select all

Global ypos,movh
InitMovie()

OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget(1,5,5,390,290)

AddGadgetItem(1,-1,"2")
AddGadgetItem(1,-1,"3")
AddGadgetItem(1,0,"1")
CloseGadgetList()

LoadMovie(0,"e:\wanted.avi")
ypos = (265-(MovieHeight(0)*384/MovieWidth(0)))/2
movh = MovieHeight(0)*384/MovieWidth(0)
SetGadgetState(1,0)

Repeat
 Event = WaitWindowEvent()
    If Event=#PB_Event_Gadget 
        Num =GetGadgetState(1) 
        Result$ = GetGadgetItemText(1, Num,0)
        If Result$ = "2"
            If Movieflag = 0
                PlayMovie(0,GetTopWindow_(GadgetID(1)))
                ResizeMovie(0,0,ypos,384,movh)
            Else
                ResumeMovie(0)
            EndIf 
        Else
            If MovieStatus(0) > 0
               PauseMovie(0)
               Movieflag = 1
            EndIf
        EndIf
    EndIf
Until Event = #PB_Event_CloseWindow
FreeMovie(0)
Egypt my love
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Play a video on a PanelGadget?

Post by RASHAD »

Tip # 3

Code: Select all

Global pHnd,TNo,ypos,movh
Global Dim tHnd(2)
TNo = 0
InitMovie()

Procedure tHndProcess(wHnd,lParam)
  tHnd(TNo) = wHnd
  TNo = TNo+1  
  EnumChildWindows_(wHnd,@tHndProcess(),lParam+1)  
  ProcedureReturn #True
EndProcedure

  OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
         
  pHnd=PanelGadget(1,5,5,390,290)
      AddGadgetItem(1, -1, "1")
      AddGadgetItem(1, -1, "2")
      AddGadgetItem(1, -1, "3")
      CloseGadgetList()
      
EnumChildWindows_(pHnd,@tHndProcess(), 0)

LoadMovie(0,"e:\wanted.avi")
ypos = (265-(MovieHeight(0)*384/MovieWidth(0)))/2
movh = MovieHeight(0)*384/MovieWidth(0)

Repeat
 Event = WaitWindowEvent()
    If Event=#PB_Event_Gadget 
        Num =GetGadgetState(1) 
        Result$ = GetGadgetItemText(1, Num,0)
        If Result$ = "2"
            If Movieflag = 0
                PlayMovie(0,tHnd(1))
                ResizeMovie(0,0,ypos,384,movh)
            Else
                ResumeMovie(0)
            EndIf 
        Else
            If MovieStatus(0) > 0
               PauseMovie(0)
               Movieflag = 1
            EndIf
        EndIf
    EndIf
Until Event = #PB_Event_CloseWindow
FreeMovie(0)
Have fun
Egypt my love
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Play a video on a PanelGadget?

Post by PB »

A funny observation about this thread: nobody replied for 5 days to my original post, until I posted a non-working example. Very bizarre! It's like people are reluctant to help until they have something to work off. Interesting, them humans. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Play a video on a PanelGadget?

Post by Fred »

I think it's boring to write a full snippet just to try to reproduce the error. Posting the non-working one indeed set up a base where you can directly investigate.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Play a video on a PanelGadget?

Post by RASHAD »

@Fred
There is no any errors Freak show us that
So why you talk like that?
We are posting different working tips to PB that is all is that against your rules?
So if we have a good tip from FB or NM we should stop thinking
What is wrong with you guys if I wrote attractive title so I am heating up and one of the mods change it just
like that by no meaning title
If I tried not to follow the others It is boring
I do not code for living but for learning and get a few moments of joy
Will you please read the thread one more time again
No boring just different ideas

@PB
We were (at least me) confused bet using panel tab or OpenWindowedScreen untill you posted your snippet that is it
Egypt my love
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Play a video on a PanelGadget?

Post by Fred »

RASHAD: you probably didn't understood what i wrote, it was just a justification to PB wondering.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Play a video on a PanelGadget?

Post by RASHAD »

Sorry Fred
I knew you are dealing with the problems in a very civilized way
Just I wondered

Have a good day

Now I can go to sleep
Egypt my love
Post Reply