Movie library demo doesn't work on Mac?

Mac OSX specific forum
User avatar
USCode
Addict
Addict
Posts: 910
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle, USA

Movie library demo doesn't work on Mac?

Post by USCode »

Does the Movie library demo code work for anyone on their Mac?
I have mp4 movies (made with iMovie) that run fine with QuickTime on my Mac, but this code fails at LoadMovie:

Code: Select all

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

MovieName$ = OpenFileRequester("Choose the movie to play", "", "Movie files|*.avi;*.mpg|All Files|*.*", 0)
If MovieName$
  If LoadMovie(0, MovieName$)
  
    OpenWindow(0, 100, 150, MovieWidth(0), MovieHeight(0), "PureBasic - Movie")
    PlayMovie(0, WindowID(0))
      
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  Else
    MessageRequester("Error", "Can't load the movie...", 0)
  EndIf
EndIf 
PB: 5.73LTS
OSX: Catalina 10.15.7
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3762
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Movie library demo doesn't work on Mac?

Post by wilbert »

I guess it still isn't fixed
viewtopic.php?f=24&t=73941
Windows 11, macOS 10.15 Catalina
Rinzwind
Enthusiast
Enthusiast
Posts: 536
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Movie library demo doesn't work on Mac?

Post by Rinzwind »

:shock:
User avatar
USCode
Addict
Addict
Posts: 910
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle, USA

Re: Movie library demo doesn't work on Mac?

Post by USCode »

Just so I understand correctly, for up-to-date systems, the Movie library hasn't worked on the Mac since 2019??
If so, should the documentation be updated from "All" to "Windows, Linux" until it is fixed?

Are there other PB libraries in a similar predicament? :?:
User avatar
deseven
Enthusiast
Enthusiast
Posts: 318
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Movie library demo doesn't work on Mac?

Post by deseven »

USCode wrote: Wed Nov 10, 2021 5:43 pm Just so I understand correctly, for up-to-date systems, the Movie library hasn't worked on the Mac since 2019??
If so, should the documentation be updated from "All" to "Windows, Linux" until it is fixed?
Ha, welcome to PureBasic for macOS!

Here's the incomplete list of broken or semi-broken things:
  • movie library (not working with recent OS versions)
  • sound library (not working with recent OS versions, memory leaks in the older ones)
  • http library (random crashes, inconsistent behavior)
  • process library (multiple bugs here and there, very slow)
  • drag'n'drop library (doesn't follow macOS way of handling such things, buggy)
  • 2D drawing library (in many ways works really different compared to other platforms)
  • status bar library (doesn't support macOS themes which were introduced in 2014)
  • all 2d/3d games libraries (they use opengl - deprecated since 2014 - and have many bugs)
That's just what I personally encountered or know from forums posts.

All in all, macOS version of PB is on life support for several years already, only the most critical bugs are being fixed (like when you can't use PB at all and compile even the simplest programs). What is even worse - a lot of stuff may require a complete rewrite, I don't even expect any good news at this point.
User avatar
USCode
Addict
Addict
Posts: 910
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle, USA

Re: Movie library demo doesn't work on Mac?

Post by USCode »

Thanks deseven,
I’ve been away from PB for quite some time, but had an idea I wanted to implement in PB.
Unfortunately I guess the state of PB on the Mac precludes that. :(
User avatar
USCode
Addict
Addict
Posts: 910
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle, USA

Re: Movie library demo doesn't work on Mac?

Post by USCode »

Does the new upcoming PB version 6.0 address any of these issues with PB on macOS?
User avatar
deseven
Enthusiast
Enthusiast
Posts: 318
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Movie library demo doesn't work on Mac?

Post by deseven »

Looks like status bar library was updated, the OSVersion() finally supports newer OS versions and there were reports that movie library actually works again too, but as far as I know that's more or less it.

Still, since there was absolutely zero info about 2 out of 3 of those fixes in the beta changelog, maybe some other stuff was silently fixed too. I guess the only way to find out is to actually test it all yourself. With no real issue tracker there is no transparency here, unfortunately.
User avatar
USCode
Addict
Addict
Posts: 910
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle, USA

Re: Movie library demo doesn't work on Mac?

Post by USCode »

Upgraded the Movie library on OS X to support modern OS X version
https://www.purebasic.fr/english/viewto ... 10#p583910

Haven't tried it yet, but maybe this change in version 6.0 will better address the Movie Library issues on OSX ... :?:
User avatar
fsw
Addict
Addict
Posts: 1553
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: Movie library demo doesn't work on Mac?

Post by fsw »

The code in the first post in this thread works with mp4.
(suppose the help is still the old one as it still says: " ...it uses QuickTime technology...")

Observation:

Code: Select all

If LoadMovie(0, MovieName$)
doesn't seem to work right as when I loaded webm or mkv files it loaded the files, but no window showed up...
If webm or mkv movie files are not allowed movie formats, the LoadMovie function should do it's job.
No?

BTW: don't expect to see any of the 2 possible user interfaces for movies as there are no movie functions showing up.
(on macOS the are 2 ui's, one with a floating movie function bar that sits on top of the movie, and the other where the movie functions are at the bottom of the movie gadget - normally these 2 ui's show up when the cursor is on top of the window and it moves...)

I am to provide the public with beneficial shocks.
Alfred Hitshock
User avatar
mk-soft
Addict
Addict
Posts: 3804
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Movie library demo doesn't work on Mac?

Post by mk-soft »

QuickTime is no longer used from Beta 7.

You only realise that there is no decoder when you query MovieInfo (frames per second) or perform PlayMovie and the picture 'disable play' appears.
The automatic video control is probably not implemented.

Maybe a bug or internal macOS features

To test it, I first had to convert the video 'Big Buck Bunny' from AVI to MOV.

Full movie player for testing ...

Code: Select all

;-TOP by mk-soft, v1.01.3, 07.05.2022 - 15.05.2022

#ProgramTitle = "Main Movie Window"
#Version = "v1.01.3"

Enumeration Windows
  #Main
  #Dialog
EndEnumeration

Enumeration Menubar
  #MainMenu
EndEnumeration

Enumeration MenuItems
  #MainMenuExitApplication
  #MainMenuOpen
  #MainMenuPlay
  #MainMenuPause
  #MainMenuResume
  #MainMenuStop
  #MainMenuSeekPlus
  #MainMenuSeekMinus
  #MainMenuVolumen
  #MainMenuBalance
EndEnumeration

Enumeration Gadgets
  #DialogTextVolumen
  #DialogTextBalance
  #DialogScrollVolumen
  #DialogScrollBalance
EndEnumeration

Enumeration Statusbar
  #MainStatusBar
EndEnumeration

Global ExitApplication

Global movie.s, movieID, frames_per_second, frame_pos, frame_len, movie_dx, movie_dy
Global volumen = 100
Global balance = 0

; ----

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(#Main)
  dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
  ; Resize gadgets
  If IsMovie(0)
    ResizeMovie(0, 0, 0, dx, dy)
  EndIf
EndProcedure

; ----

Procedure UpdateStatus()
  Protected info.s, time
  info = "Frames: " + Str(frame_pos) + " / " + Str(frame_len)
  StatusBarText(#MainStatusBar, 0, info)
  If frames_per_second
    time = frame_pos * 1000 / frames_per_second
    info = RSet(Str(time / 60), 3, "0") + ":" + RSet(Str(time % 60), 2, "0")
    time = frame_len * 1000 / frames_per_second
    info + " / " + RSet(Str(time / 60), 3, "0") + ":" + RSet(Str(time % 60), 2, "0")
  Else
    info = "Invalid frame data"
  EndIf
  StatusBarText(#MainStatusBar, 1, info)
EndProcedure

; ----

Procedure Dialog()
  If OpenWindow(#Dialog, #PB_Ignore, #PB_Ignore, 340, 100, "Audio", #PB_Window_Tool)
    TextGadget(#DialogTextVolumen, 10, 10, 120, 25, "Volumen " + volumen)
    TextGadget(#DialogTextBalance, 10, 50, 120, 25, "Balance " + balance)
    ScrollBarGadget(#DialogScrollVolumen, 140, 10, 180, 30, 0, 100, 1)
    ScrollBarGadget(#DialogScrollBalance, 140, 50, 180, 30, 0, 200, 1)
    SetGadgetState(#DialogScrollVolumen, volumen)
    SetGadgetState(#DialogScrollBalance, balance + 100)
  EndIf
EndProcedure

; ----

Procedure Main()
  Protected dx, dy, status
  
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 600, 400, #ProgramTitle , #MainStyle)
    ; Menu
    CreateMenu(#MainMenu, WindowID(#Main))
    MenuTitle("File")
    MenuItem(#MainMenuOpen, "&Open Movie")
    MenuBar()
    MenuItem(#MainMenuExitApplication, "E&xit")
    MenuTitle("Control")
    MenuItem(#MainMenuPlay, "Play")
    MenuItem(#MainMenuPause, "Pause")
    MenuItem(#MainMenuResume, "Resume")
    MenuItem(#MainMenuStop, "Stop")
    MenuBar()
    MenuItem(#MainMenuSeekPlus, "Seek +")
    MenuItem(#MainMenuSeekMinus, "Seek -")
    MenuTitle("Audio")
    MenuItem(#MainMenuVolumen, "Volumen")
    MenuItem(#MainMenuBalance, "Balance")
    
    ; For Mac
    CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
      If Not IsMenu(#MainMenu)
        CreateMenu(#MainMenu, WindowID(#Main))
      EndIf
      MenuItem(#PB_Menu_About, "")
      MenuItem(#PB_Menu_Preferences, "")
    CompilerEndIf
    
    ; StatusBar  
    CreateStatusBar(#MainStatusBar, WindowID(#Main))
    AddStatusBarField(160)
    AddStatusBarField(120)
    AddStatusBarField(#PB_Ignore)
    StatusBarText(#MainStatusBar, 0, " " + #Version)
    
    ; Gadgets
    dx = WindowWidth(#Main)
    dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
    
    ; Bind events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
    
    ; Main loop
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case #Main
              ExitApplication = #True
              
            Case #Dialog
              CloseWindow(#Dialog)
              
          EndSelect
          
        Case #PB_Event_Menu
          Select EventMenu()
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS   
              Case #PB_Menu_About
                MessageRequester("Info", #ProgramTitle + " " + #Version)
                
              Case #PB_Menu_Preferences
                
              Case #PB_Menu_Quit
                PostEvent(#PB_Event_CloseWindow, #Main, #Null)
                
            CompilerEndIf
              
            Case #MainMenuExitApplication
              PostEvent(#PB_Event_CloseWindow, #Main, #Null)
              
            Case #MainMenuOpen
              movie = OpenFileRequester("Choose the movie to play", "", "Movie files|*.avi;*.mpg|All Files|*.*", 0)
              If movie
                If movieID
                  RemoveWindowTimer(#Main, 1)
                  StopMovie(0)
                  FreeMovie(0)
                EndIf
                movieID = LoadMovie(0, movie)
                If movieID
                  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
                    ;- Windows MovieInfo Frames per second * 1000
                    frames_per_second = (MovieInfo(0, 0) + 1) * 1000
                  CompilerElse
                    frames_per_second = MovieInfo(0, 0)
                  CompilerEndIf
                  frame_len = MovieLength(0)
                  frame_pos = MovieStatus(0)
                  movie_dx = MovieWidth(0)
                  movie_dy = MovieHeight(0)
                  If movie_dx > 0 And movie_dy > 0
                    dy = movie_dy + StatusBarHeight(#MainStatusBar) + MenuHeight()
                    ResizeWindow(#Main, #PB_Ignore, #PB_Ignore, movie_dx, dy)
                  EndIf
                  UpdateStatus()
                  StatusBarText(#MainStatusBar, 2, movie)
                  MovieAudio(0, volumen, balance)
                Else
                  StatusBarText(#MainStatusBar, 1, "")
                  MessageRequester("Error", "Can't load the movie...", #PB_MessageRequester_Error)
                EndIf
              EndIf
              
            Case #MainMenuPlay
              If movieID
                PlayMovie(0, WindowID(#Main))
                AddWindowTimer(#Main, 1, 1000)
              EndIf
              
            Case #MainMenuPause
              If movieID
                PauseMovie(0)
              EndIf
              
            Case #MainMenuResume
              If movieID
                ResumeMovie(0)
              EndIf
              
            Case #MainMenuStop
              If movieID
                StopMovie(0)
                RemoveWindowTimer(#Main, 1)
              EndIf
              
            Case #MainMenuSeekPlus
              If movieID
                frame_pos + (frames_per_second * 60 / 1000) ; Add 60s
                If frame_pos > frame_len
                  frame_pos = frame_len
                EndIf
                MovieSeek(0, frame_pos)
              EndIf
              
            Case #MainMenuSeekMinus
              If movieID
                frame_pos - (frames_per_second * 60 / 1000) ; Sub 60s
                If frame_pos < 0
                  frame_pos = 0
                EndIf
                MovieSeek(0, frame_pos)
              EndIf
              
            Case #MainMenuVolumen
              If Not IsWindow(#Dialog)
                Dialog()
              EndIf
              
            Case #MainMenuBalance
              If Not IsWindow(#Dialog)
                Dialog()
              EndIf
            
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case  #DialogScrollVolumen
              volumen = GetGadgetState(#DialogScrollVolumen)
              SetGadgetText(#DialogTextVolumen, "Volumen " + volumen)
              If movieID
                MovieAudio(0, volumen, balance)
              EndIf
              
            Case  #DialogScrollBalance
              balance = GetGadgetState(#DialogScrollBalance) - 100
              SetGadgetText(#DialogTextBalance, "Balance " + balance)
              If movieID
                MovieAudio(0, volumen, balance)
              EndIf
              
            
          EndSelect
          
        Case #PB_Event_Timer
          Select EventTimer()
            Case 1
              If movieID
                status = MovieStatus(0)
                If status > 0
                  ;- Simulate frame postion (Raspberry)
                  If status = 1
                    frame_pos + (frames_per_second / 1000)
                  Else
                    frame_pos = status
                  EndIf
                  UpdateStatus()
                EndIf
              EndIf
          EndSelect
          
      EndSelect
      
    Until ExitApplication
    
  EndIf
  
EndProcedure

If InitMovie()
  Main()
Else
  MessageRequester("Error", "Can't initialize movie playback !", #PB_MessageRequester_Error)
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply