Page 2 of 2

Re: Play a video on a PanelGadget?

Posted: Wed Oct 21, 2009 3:30 am
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)

Re: Play a video on a PanelGadget?

Posted: Wed Oct 21, 2009 8:28 am
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

Re: Play a video on a PanelGadget?

Posted: Wed Oct 21, 2009 9:58 am
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. :)

Re: Play a video on a PanelGadget?

Posted: Wed Oct 21, 2009 10:50 am
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.

Re: Play a video on a PanelGadget?

Posted: Wed Oct 21, 2009 11:59 am
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

Re: Play a video on a PanelGadget?

Posted: Wed Oct 21, 2009 2:57 pm
by Fred
RASHAD: you probably didn't understood what i wrote, it was just a justification to PB wondering.

Re: Play a video on a PanelGadget?

Posted: Wed Oct 21, 2009 3:18 pm
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