Page 1 of 2
Play a video on a PanelGadget?
Posted: Thu Oct 15, 2009 2:20 pm
by PB
Is there any way to use LoadMovie to play a video on a specific X/Y position on a PanelGadget? Every time I try the video seems to be overlayed on top of it, so that if I switch panels, the video is still showing. I was using OpenWindowedScreen to play the video.
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 12:14 pm
by PB
Here's a modified version of the OpenWindowedScreen example from the Help. What I want it to do, is only show the video when tab 2 is selected, and hide the video when tab 1 is selected. I can't work it out. Do you think it's possible?
Code: Select all
If InitSprite() = 0
MessageRequester("Error", "Can't open screen & sprite enviroment!", 0)
End
EndIf
If OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 170, 135, 45, 20, "Quit")
PanelGadget(1,5,5,390,290)
AddGadgetItem(1,-1,"1")
AddGadgetItem(1,-1,"2")
CloseGadgetList()
m=OpenWindowedScreen(WindowID(0), 40, 40, 160, 160, 0, 0, 0)
If m
CreateSprite(0, 20, 20)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
EndIf
direction = 2
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget
If EventGadget() = 1
If GetGadgetState(1)=1
ShowWindow_(m,#SW_HIDE) ; Doesn't work.
Else
ShowWindow_(m,#SW_SHOW) ; Doesn't work.
EndIf
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
DisplaySprite(0, x, x)
x + direction
If x > 140 : direction = -2 : EndIf
If x < 0 : direction = 2 : EndIf
Delay(1)
ForEver
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 12:26 pm
by Fluid Byte
This works for me:
Code: Select all
InitMovie()
OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 170, 135, 45, 20, "Quit")
PanelGadget(1,5,5,390,290)
AddGadgetItem(1,-1,"1")
AddGadgetItem(1,-1,"2")
CloseGadgetList()
LoadMovie(0,"*yourmovie*")
PlayMovie(0,GetWindow_(GadgetID(1),#GW_CHILD))
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Use ResizeMovie() to relocate the playing area.
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 12:33 pm
by PB
> GetWindow_(GadgetID(1),#GW_CHILD)
That's the magic stuff!

Thanks very much, FB!
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 12:45 pm
by eddy
Does it work with this command
OpenGadgetList(1,0) ?
Sorry I can't test this code. (PB not installed on my notebook)
Code: Select all
InitMovie()
OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 170, 135, 45, 20, "Quit")
PanelGadget(1,5,5,390,290)
AddGadgetItem(1,-1,"1")
AddGadgetItem(1,-1,"2")
CloseGadgetList()
LoadMovie(0,"*yourmovie*")
PlayMovie(0,OpenGadgetList(1,0)) ; <--- display the movie inside the first tab panel (don't know if it works)
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 1:03 pm
by PB
> PlayMovie(0,OpenGadgetList(1,0))
Yep, that works for me too.
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 3:02 pm
by netmaestro
The OpenGadgetList version is preferable here because you can choose any panel. The GetWindow code is only good for the first panel.
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 3:13 pm
by RASHAD
OpenGadgetList does not work with Windows 7 x64 PB x64
GetWindow_(GadgetID(1),#GW_CHILD) is ok
But PB want the movie in panel 2
here is my tip
Code: Select all
InitMovie()
OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 170, 135, 45, 20, "Quit")
PanelGadget(1,5,5,390,290)
AddGadgetItem(1,-1,"2")
AddGadgetItem(1,0,"1")
CloseGadgetList()
LoadMovie(0,"**your movie here**")
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,(265-(MovieHeight(0)*384/MovieWidth(0)))/2,384,MovieHeight(0)*384/MovieWidth(0))
Else
ResumeMovie(0)
EndIf
ElseIf Result$ = "1"
If IsMovie(0)
PauseMovie(0)
Movieflag = 1
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
Have fun
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 5:39 pm
by eddy
RASHAD wrote:OpenGadgetList does not work with Windows 7 x64 PB x64
Perhaps a bug

But does PB support Win7 officially ?
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 5:43 pm
by RASHAD
Yes eddy I think that it is a bug in PB x64
Will you please check again and report if it is a bug
OpenGadgetList is the proper command to be used
thanks
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 9:40 pm
by eddy
I have a x86. I think you can report this problem.
[Edit]
it's not a bug
Re: Play a video on a PanelGadget?
Posted: Tue Oct 20, 2009 10:27 pm
by utopiomania
Place a webgadget on the panelgadget, and some html in it with either the dynsrc or object tag to play the video?
Re: Play a video on a PanelGadget?
Posted: Wed Oct 21, 2009 12:28 am
by freak
OpenGadgetList() does not return a value. Whatever you get on x86 is just a coincidence.
Re: Play a video on a PanelGadget?
Posted: Wed Oct 21, 2009 12:39 am
by netmaestro
Ha, I thought it was meant to. If not, then this (windows only) will get it, iirc by GPI:
Code: Select all
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
Re: Play a video on a PanelGadget?
Posted: Wed Oct 21, 2009 1:11 am
by eddy
I see. Thx Freak for this confirmation.
Here is a fixed version:
Code: Select all
InitMovie()
MovieName$=OpenFileRequester("Choose the movie to play", "", "Movie/Audio files|*.avi;*.mpg;*.asf;*.mp3;*.wav|All Files|*.*", 0)
If MovieName$
OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 170, 135, 45, 20, "Quit")
PanelGadget(1, 5, 5, 390, 290)
AddGadgetItem(1, -1, "1")
AddGadgetItem(1, -1, "2")
CloseGadgetList()
OpenGadgetList(1, 0)
w=GetGadgetAttribute(1, #PB_Panel_ItemWidth)
h=GetGadgetAttribute(1, #PB_Panel_ItemHeight)
MovieContainer=ContainerGadget(2, 0, 0, w, h, #PB_Container_BorderLess)
LoadMovie(0, MovieName$)
ResizeMovie(0, 0, 0, w, h)
PlayMovie(0, MovieContainer) ; <--- display the movie inside the first tab panel (don't know if it works)
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
EndIf