Page 1 of 1

PLay Movie Full Screen DirectX ???

Posted: Fri Oct 18, 2013 7:58 am
by DaylightDreamer
Is there a proper way to play a movie in the OpenedScrenn ??? RenderMovieFrame seems to be removed in 5.20 ....

Re: PLay Movie Full Screen DirectX ???

Posted: Fri Oct 18, 2013 10:54 am
by TI-994A
Hello DaylightDreamer. This example works with two short WMV and AVI videos from the web:

Code: Select all

InitNetwork()

selection.s = InputRequester("Select Video:", "Enter 1 for WMV video (100KB) " + 
                                              "or 2 for AVI video (1MB)", "")
If selection = "2"
  ReceiveHTTPFile("https://dl.dropboxusercontent.com/u/38177172/dominoPCs.avi",
                  GetTemporaryDirectory() + "dominoPCs.avi")
  videoFile.s = GetTemporaryDirectory() + "dominoPCs.avi"
Else
  ReceiveHTTPFile("https://dl.dropboxusercontent.com/u/38177172/catfight.wmv",
                  GetTemporaryDirectory() + "catfight.wmv")
  videoFile.s = GetTemporaryDirectory() + "catfight.wmv"
EndIf

If videoFile And 
   InitMovie() And
   InitSprite() And
   InitKeyboard() And 
   LoadMovie(0, videoFile)
  ResizeMovie(0, 0, 0,
              GetSystemMetrics_(#SM_CXSCREEN),
              GetSystemMetrics_(#SM_CYSCREEN))
  OpenScreen(GetSystemMetrics_(#SM_CXSCREEN),
             GetSystemMetrics_(#SM_CYSCREEN),
             16, "", #PB_Screen_WaitSynchronization)
  PlayMovie(0, ScreenID())
  MovieAudio(0, 50, 0)
  Repeat
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)  
Else
  MessageRequester("Fullscreen Playback:", "Unable to play video.")
EndIf
Hope it works for you too. :)

Re: PLay Movie Full Screen DirectX ???

Posted: Mon Oct 21, 2013 9:07 am
by DaylightDreamer
Nope :(

It doesn't work.
I have try several codecs, I'm using Windows 7

Re: PLay Movie Full Screen DirectX ???

Posted: Mon Oct 21, 2013 9:49 am
by PB
Nothing but a black screen here, too.

If I download the AVI file to my desktop, though, it plays just fine.
So I obviously have the necessary codecs installed, but PureBasic
can't play it for some reason.

Re: PLay Movie Full Screen DirectX ???

Posted: Mon Oct 21, 2013 11:05 am
by JHPJHP
Just some observations:

By only changing this part of the code - it plays:

Code: Select all

OpenScreen(500, 500, 16, "", #PB_Screen_WaitSynchronization)
Change this part as well and it plays with less distortion: :P

Code: Select all

ResizeMovie(0, 0, 0, 500, 500)

Re: PLay Movie Full Screen DirectX ???

Posted: Mon Oct 21, 2013 11:29 am
by TI-994A
DaylightDreamer wrote:It doesn't work...
PB wrote:Nothing but a black screen here, too...
Hi guys! Please try changing the color depth from 16 to 32:

Code: Select all

  OpenScreen(GetSystemMetrics_(#SM_CXSCREEN),
             GetSystemMetrics_(#SM_CYSCREEN),
             32, "", #PB_Screen_WaitSynchronization)
Tested it on Windows 7/64 and it works fine. Not sure, but it could be an issue with the video card. :)

Re: PLay Movie Full Screen DirectX ???

Posted: Mon Oct 21, 2013 11:39 am
by PB
> it could be an issue with the video card

But why does it play with Media Player Classic?
Same codecs, video display, graphics card. :)

Also, changing it to a 16-bit display didn't help.

Lastly, I don't get the "Unable to play video" message.
Just a black screen until I hit Esc to end the app.

Re: PLay Movie Full Screen DirectX ???

Posted: Mon Oct 21, 2013 1:04 pm
by TI-994A
Hello PB.
PB wrote:But why does it play with Media Player Classic?
Same codecs, video display, graphics card. :)
The hardware may support the format, but we simply need to correct the configuration settings of OpenScreen() to work with it. WMP clearly detects and handles these settings automatically.
PB wrote:Also, changing it to a 16-bit display didn't help.
Are you referring to the OS display settings or the depth setting of the OpenScreen() function in the example? I suggested changing the OpenScreen() function's depth setting to 32, as such:

Code: Select all

OpenScreen(GetSystemMetrics_(#SM_CXSCREEN),
           GetSystemMetrics_(#SM_CYSCREEN),
           32, "", #PB_Screen_WaitSynchronization)
PB wrote:Lastly, I don't get the "Unable to play video" message.
Just a black screen until I hit Esc to end the app.
If the code execution reaches the "Unable to play video" error message, that would mean that either the movie was not received, did not load, or one of the device initialisations failed. If that's the case, your issue is not with OpenScreen(). This modified example includes separate error checks. Perhaps if you give it a try, you could determine where the error lies:

Code: Select all

If InitNetwork()
  
  Macro err(msg)
    MessageRequester("Fullscreen Playback:", msg)  
  EndMacro
  
  selection.s = InputRequester("Select Video:", "Enter 1 for WMV video (100KB) " + 
                                                "or 2 for AVI video (1MB)", "")
  If selection = "2"
    fileReceived = ReceiveHTTPFile("https://dl.dropboxusercontent.com/u/38177172/dominoPCs.avi",
                                   GetTemporaryDirectory() + "dominoPCs.avi")
    videoFile.s = GetTemporaryDirectory() + "dominoPCs.avi"
  Else
    fileReceived = ReceiveHTTPFile("https://dl.dropboxusercontent.com/u/38177172/catfight.wmv",
                                   GetTemporaryDirectory() + "catfight.wmv")
    videoFile.s = GetTemporaryDirectory() + "catfight.wmv"
  EndIf
  
  If fileReceived
    If InitMovie()
      If InitSprite()
        If InitKeyboard()
          If LoadMovie(0, videoFile)
            ResizeMovie(0, 0, 0,
                        GetSystemMetrics_(#SM_CXSCREEN),
                        GetSystemMetrics_(#SM_CYSCREEN))
            OpenScreen(GetSystemMetrics_(#SM_CXSCREEN),
                       GetSystemMetrics_(#SM_CYSCREEN),
                       32, "", #PB_Screen_WaitSynchronization)
            PlayMovie(0, ScreenID())
            MovieAudio(0, 50, 0)
            Repeat
              ExamineKeyboard()
            Until KeyboardPushed(#PB_Key_Escape)  
          Else
            err("LoadMovie() failed.")
          EndIf
        Else
          err("InitKeyboard() failed.")
        EndIf
      Else
        err("InitSprite() failed.")
      EndIf
    Else
      err("InitMovie() failed.")
    EndIf
  Else
    err("Video file not received.")
  EndIf
Else
  err("InitNetwork() failed.")  
EndIf

Re: PLay Movie Full Screen DirectX ???

Posted: Mon Oct 21, 2013 2:58 pm
by PB
Oops, changing from 16-bit to 32-bit makes it work! :)
For some reason I never changed it from 16. My bad!

Thanks for your patience and help, and sorry that it
was my fault all along. :oops:

Re: PLay Movie Full Screen DirectX ???

Posted: Wed Oct 23, 2013 11:02 am
by DaylightDreamer
Yep it works like that,

However this seems to work only with native OS resolution
Once you try to set different resolution it doesn't open

Besides this seem not DirectX playback
What i need in fact is to render an intro movie for a game or maybe a cut scene

Re: PLay Movie Full Screen DirectX ???

Posted: Thu Oct 24, 2013 4:07 am
by TI-994A
DaylightDreamer wrote:...this seems to work only with native OS resolution
Once you try to set different resolution it doesn't open
Hi DaylightDreamer. Yes, for full screen playback it seems that the screen size must match the display resolution. However, playback at lower resolutions is still possible, but it wouldn't be full screen, as demonstrated here:

Code: Select all

If InitNetwork()
  
  Macro err(msg)
    MessageRequester("Fullscreen Playback:", msg)  
  EndMacro
  
  selection.s = InputRequester("Select Video:", "Enter 1 for WMV video (100KB) " + 
                                                "or 2 for AVI video (1MB)", "")
  If selection = "2"
    fileReceived = ReceiveHTTPFile("https://dl.dropboxusercontent.com/u/38177172/dominoPCs.avi",
                                   GetTemporaryDirectory() + "dominoPCs.avi")
    videoFile.s = GetTemporaryDirectory() + "dominoPCs.avi"
  Else
    fileReceived = ReceiveHTTPFile("https://dl.dropboxusercontent.com/u/38177172/catfight.wmv",
                                   GetTemporaryDirectory() + "catfight.wmv")
    videoFile.s = GetTemporaryDirectory() + "catfight.wmv"
  EndIf
  
  If fileReceived
    If InitMovie()
      If InitSprite()
        If InitKeyboard()
          If LoadMovie(0, videoFile)
            ResizeMovie(0, 0, 0, 400, 300)
            OpenScreen(400, 300, 32, "", #PB_Screen_WaitSynchronization)
            PlayMovie(0, ScreenID())
            MovieAudio(0, 50, 0)
            Repeat
              ExamineKeyboard()
            Until KeyboardPushed(#PB_Key_Escape)  
          Else
            err("LoadMovie() failed.")
          EndIf
        Else
          err("InitKeyboard() failed.")
        EndIf
      Else
        err("InitSprite() failed.")
      EndIf
    Else
      err("InitMovie() failed.")
    EndIf
  Else
    err("Video file not received.")
  EndIf
Else
  err("InitNetwork() failed.")  
EndIf
DaylightDreamer wrote:Besides this seem not DirectX playback
What i need in fact is to render an intro movie for a game or maybe a cut scene
PureBasic Manual - Movie wrote:Windows: as it uses the DirectX 7 technology (DirectShow), any kind of media can be played with this library: AVI, MPG, DivX, Mp3 etc.
Not really sure about this, but according to the PureBasic manual, the PlayMovie() function utilises DirectX. :)