Play a video on a PanelGadget?

Just starting out? Need help? Post your questions and find answers here.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Play a video on a PanelGadget?

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
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 »

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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Re: Play a video on a PanelGadget?

Post 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.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
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 »

> GetWindow_(GadgetID(1),#GW_CHILD)

That's the magic stuff! :) Thanks very much, FB!
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Play a video on a PanelGadget?

Post 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
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
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 »

> PlayMovie(0,OpenGadgetList(1,0))

Yep, that works for me too.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Play a video on a PanelGadget?

Post by netmaestro »

The OpenGadgetList version is preferable here because you can choose any panel. The GetWindow code is only good for the first panel.
BERESHEIT
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 »

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
Egypt my love
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Play a video on a PanelGadget?

Post by eddy »

RASHAD wrote:OpenGadgetList does not work with Windows 7 x64 PB x64
Perhaps a bug :|
But does PB support Win7 officially ?
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 »

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
Egypt my love
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Play a video on a PanelGadget?

Post by eddy »

I have a x86. I think you can report this problem.

[Edit]
it's not a bug
Last edited by eddy on Wed Oct 21, 2009 1:13 am, edited 1 time in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Re: Play a video on a PanelGadget?

Post by utopiomania »

Place a webgadget on the panelgadget, and some html in it with either the dynsrc or object tag to play the video?
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Play a video on a PanelGadget?

Post by freak »

OpenGadgetList() does not return a value. Whatever you get on x86 is just a coincidence.
quidquid Latine dictum sit altum videtur
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Play a video on a PanelGadget?

Post 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
BERESHEIT
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Play a video on a PanelGadget?

Post 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 
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Post Reply