PureBasic Forum
https://www.purebasic.fr/english/

PlayMovie
https://www.purebasic.fr/english/viewtopic.php?f=13&t=73217
Page 1 of 1

Author:  Trion [ Thu Jul 18, 2019 10:50 pm ]
Post subject:  PlayMovie

[5.71 Beta2 LTS (x32)] - Windows 10

Playmove does not work i only get a white window

PureBasic Version 5.51 (x32) is working, all versions higher than 5.51 will not work anymore

Code:
InitMovie()

OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SizeGadget | #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,"test.wmv")
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

Author:  dcr3 [ Mon Aug 26, 2019 8:56 am ]
Post subject:  Re: PlayMovie

Sorry for the earlier post. :oops:

Hope this isof any help.
Code:
´╗┐InitMovie()
flg= #PB_Window_SizeGadget | #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(0, 0, 0, 400, 300, "A screen in a window...",flg)
ButtonGadget(0, 170, 135, 45, 20, "Quit")
PanelGadget(1,5,5,390,290)
AddGadgetItem(1,-1,"2")
AddGadgetItem(1,0,"1")

ButtonGadget(16, 3, 14, 100, 20, "Open")
ButtonGadget(17, 3, 34, 100, 20, "Play")
ButtonGadget(18, 3, 56, 100, 20, "Pause")
CloseGadgetList()

LoadMovie(0,"carribean.wmv")
SetGadgetState(1,0)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      AppQuit = 1
     
    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()

    Case 16 ; "Open")
      MovieName$ = OpenFileRequester("Choose the movie to play", "", "Movie files|*.wmv|*.mp4|All Files|*.*", 0)
      LoadMovie(0, MovieName$)
   
     Case 17   ;Play
      SetGadgetState(1,1)
      If SetGadgetState(17,1)
           
      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
             
     Case 18 ;Pause
          If SetGadgetState(18,1)
           PauseMovie(0)
          Else
          ResumeMovie(0)
          EndIf
     EndSelect

  EndSelect
Until AppQuit

Author:  Fred [ Sun Sep 22, 2019 4:57 pm ]
Post subject:  Re: PlayMovie

Since 5.60, the PanelGadget() can have 2 EventType(): change and resize. Resize is always fired when a new panel is first displayed to allow layout. So you will need to take that in account in your code.

Code:
InitMovie()

OpenWindow(0, 0, 0, 400, 300, "A screen in a window...", #PB_Window_SizeGadget | #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,"720.wmv")
SetGadgetState(1,0)

Repeat
  Event = WaitWindowEvent()
  If Event=#PB_Event_Gadget
   
    If EventGadget() = 1 And EventType() = #PB_EventType_Change ; Important to filter on the correct event type
      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
  EndIf
Until Event = #PB_Event_CloseWindow

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/