Movie Commands fail in Threads

Windows specific forum
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Movie Commands fail in Threads

Post by Paul »

PlayMovie works fine normally but fails if you try to use in a Thread...

Working...

Code: Select all

InitMovie()  

Procedure Thread(flag.l)
  If OpenWindow(1,0,0,640,480,"")             
    LoadMovie(1,"AnimBar.mpg")
    PlayMovie(1,WindowID(1))

    quitThread=0
    Repeat
      If WindowEvent()=#PB_Event_CloseWindow
        quitThread=1
      EndIf

      Delay(1)
    Until quitThread
  EndIf
EndProcedure  
 
 
 
If OpenWindow(0,0,0,200,100,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  Thread(0)
  
  Repeat    
  Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf

Non working in Thread...

Code: Select all

InitMovie()  

Procedure Thread(flag.l)
  If OpenWindow(1,0,0,640,480,"")             
    LoadMovie(1,"AnimBar.mpg")
    PlayMovie(1,WindowID(1))   ;<<---- ERRORS ON THIS LINE

    quitThread=0
    Repeat
      If WindowEvent()=#PB_Event_CloseWindow
        quitThread=1
      EndIf

      Delay(1)
    Until quitThread
  EndIf
EndProcedure  
 
 
 
If OpenWindow(0,0,0,200,100,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  CreateThread(@Thread(),0)

  Repeat    
  Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf
Image Image
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Well, the commands are DirectX based, and DirectX has problems with threads. There is not much way around that.
quidquid Latine dictum sit altum videtur
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

:cry:
Image Image
Post Reply