Linux Movie

Everything else that doesn't fall into one of the other PB categories.
k3pto
User
User
Posts: 97
Joined: Sat Jan 17, 2015 5:24 pm

Linux Movie

Post by k3pto »

I am using Linux Mint 22.3 and PB 6.30 and showing a movie on two monitors and have encountered a problem.
The following refers to the program below:
1) line 59 in, line 66 commented: works as expected.
2) both commented
a) Start: both run
b) Stop then Start: movie_0 = nothing, movie_1 = runs
c) Pause: movie_0 runs, movie_1 pauses
d) Resume: movie_0 continues , movie_1 resumes now out of sync
3) both in
a) Start: movie_0 = runs, movie_1 = nothing
b) Pause: movie_0 = pauses, movie_1 = runs
c) Resume: both run out of sync
d) Pause: movie_0 = pauses, movie_1 = continues
4) line 59 commented, 66 in:
a) Start: movie_0 = shows screen but no video, movie_1 = nothing
b) Pause: both run
c) Pause and Resume: no effect

Code: Select all

; started with the PB example Movie.pb
; see lines 59 and 66

EnableExplicit
Define MonitorCount, movieName$, WinEvent, Event, Gadget, msg$
Define button_y, button_x, button_dx, bg_start, bg_stop, bg_pause, bg_resume, bg_exit, tb_state
Define movie_0, Wind_0, Wind_0_ID, Wind_0_x, Wind_0_y, Wind_0_dx, Wind_0_dy, status_0
Define movie_1, Wind_1, Wind_1_ID, Wind_1_x, Wind_1_y, Wind_1_dx, Wind_1_dy, status_1

If InitMovie() = 0
  MessageRequester("Error", "Can't initialize movie playback !", 0)
  End
EndIf
MonitorCount = ExamineDesktops()

movieName$ = "/home/larry/Desktop/Because He Lives.mp4"
;movie_0 = LoadMovie(#PB_Any, MovieName$)
;Wind_0 = OpenWindow(#PB_Any, 100, 150, MovieWidth(movie_0), MovieHeight(movie_0)+200, "PureBasic - Movie", #PB_Window_SystemMenu)
Wind_0_x		= DesktopX(0)+50
Wind_0_y		= DesktopY(0)+50
Wind_0_dx	= DesktopWidth(0)-100
Wind_0_dy	= DesktopHeight(0)-200
Wind_0		= OpenWindow(#PB_Any, 0, 0, Wind_0_dx, Wind_0_dy, "PureBasic - Movie", #PB_Window_SystemMenu)
Wind_0_ID	= WindowID (Wind_0)
SetWindowColor( Wind_0, RGB (210,232,255) )

button_y 	= Wind_0_dy - 100
button_x 	= 100 : button_dx = 100
bg_start		= ButtonGadget ( #PB_Any, button_x, button_y, 100, 20, "Start" ) : button_x + 110
bg_stop		= ButtonGadget ( #PB_Any, button_x, button_y, 100, 20, "Stop" ) : button_x + 110
bg_pause		= ButtonGadget ( #PB_Any, button_x, button_y, 100, 20, "Pause" ) : button_x + 110
bg_resume	= ButtonGadget ( #PB_Any, button_x, button_y, 100, 20, "Resume" ) : button_x + 110
bg_exit		= ButtonGadget ( #PB_Any, button_x, button_y, 100, 20, "EXIT" ) : button_x + 110
tb_state		= TextGadget	( #PB_Any, 100, button_y+30, 200, 20, "Stoped", #PB_Text_Border )

If MonitorCount = 2
;       movie_1		= LoadMovie(#PB_Any, MovieName$)
        Wind_1_x		= DesktopX(1)
        Wind_1_dx	= DesktopWidth(1)
        Wind_1_dy	= DesktopHeight(1)
        Wind_1		= OpenWindow ( #PB_Any, Wind_1_x, 0, Wind_1_dx, Wind_1_dy,"", #PB_Window_BorderLess | #PB_Window_Maximize )
        Wind_1_ID	= WindowID (Wind_1)
EndIf

movie_0 = 0 : movie_1 = 0
Repeat
        WinEvent = WaitWindowEvent()
        If Event = #PB_Event_CloseWindow
                End
        EndIf
        Event = EventType()
        Gadget = EventGadget()
        If gadget = bg_start
                FreeMovie (#PB_All)
                movie_0 = LoadMovie(#PB_Any, MovieName$)
                ResizeMovie ( movie_0, Wind_0_x, Wind_0_y, Wind_0_dx-100, Wind_0_dy-200 )
                PlayMovie(movie_0, Wind_0_ID)
                MovieAudio (movie_0, 99, 0 )
                While MovieStatus(movie_0) <= 0 : Wend				; comment and it breaks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                PauseMovie ( movie_0 )
                If MonitorCount = 2
                        movie_1 = LoadMovie(#PB_Any, MovieName$)
                        ResizeMovie ( movie_1, 0, 0, WindowWidth(Wind_1), WindowHeight(Wind_1) )
                        PlayMovie(movie_1, Wind_1_ID)
                        MovieAudio (movie_1, 0, 0 )
;                       While MovieStatus(movie_1) <= 0 : Wend			; uncomment and it breaks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                        PauseMovie ( movie_1 )
                EndIf
                ResumeMovie ( movie_0 )
                If MonitorCount = 2 : ResumeMovie ( movie_1 ) : EndIf
                msg$ = "Running "
        EndIf
        If Gadget = bg_stop
                StopMovie ( movie_0 )
                If MonitorCount = 2 : StopMovie ( movie_1 ) : EndIf
                msg$ = "Stopped "
                FreeMovie (#PB_All)
                movie_0 = 0 : movie_1 = 0
        EndIf
        If Gadget = bg_pause
                PauseMovie ( movie_0 )
                If MonitorCount = 2 : PauseMovie ( movie_1 ) : EndIf
                msg$ = "Paused "
        EndIf
        If Gadget = bg_resume
                If MovieStatus(movie_0) = -1 : ResumeMovie ( movie_0 ) : EndIf
                If MonitorCount = 2 And MovieStatus(movie_1) = -1 : ResumeMovie ( movie_1 ) : EndIf
                msg$ = "Running "
        EndIf
        If Gadget = bg_exit : End : EndIf
        If movie_0 : status_0 = MovieStatus(movie_0) : EndIf
        If movie_1 : status_1 = MovieStatus(movie_1) : EndIf
        If msg$ : SetGadgetText(tb_state, msg$ + Str(status_0) + " " + Str(status_1) ) : msg$ = "" : EndIf
ForEver
Last edited by k3pto on Thu Feb 05, 2026 8:11 pm, edited 1 time in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 6602
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Linux Movie

Post by mk-soft »

Give me your IP address. Then we can load the code from your computer and see where the problem is :mrgreen:
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
k3pto
User
User
Posts: 97
Joined: Sat Jan 17, 2015 5:24 pm

Re: Linux Movie

Post by k3pto »

Hi mk-soft,
The entire program, except for the video I used, is in my original entry. What else do you need?
User avatar
mk-soft
Always Here
Always Here
Posts: 6602
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Linux Movie

Post by mk-soft »

Without testing it further ...

You must not interrupt the event loop (WaitWindowEvent). This must always go through, otherwise no events such as operator input, update of gadgets can be executed

Code: Select all

While MovieStatus(movie_0) <= 0 : Wend
Something like that can't be an event loop. Use an IF : EndIf.
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
k3pto
User
User
Posts: 97
Joined: Sat Jan 17, 2015 5:24 pm

Re: Linux Movie

Post by k3pto »

Do you mean something like this:

Code: Select all

while 1
    i = MovieStatus(movie_0)
    if i <= 0 : break : endif
wend
User avatar
mk-soft
Always Here
Always Here
Posts: 6602
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Linux Movie

Post by mk-soft »

No,

never "While : Wend" inside event loop, Use WaitWindowEvent(10) <- with Timeout and check MovieState with If ...
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
k3pto
User
User
Posts: 97
Joined: Sat Jan 17, 2015 5:24 pm

Re: Linux Movie

Post by k3pto »

Hi mk-soft,

OK. I will try it later today. Thanks for the tip.
Post Reply