PLay Movie Full Screen DirectX ???

Just starting out? Need help? Post your questions and find answers here.
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

PLay Movie Full Screen DirectX ???

Post by DaylightDreamer »

Is there a proper way to play a movie in the OpenedScrenn ??? RenderMovieFrame seems to be removed in 5.20 ....
User avatar
TI-994A
Addict
Addict
Posts: 2752
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PLay Movie Full Screen DirectX ???

Post 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. :)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Re: PLay Movie Full Screen DirectX ???

Post by DaylightDreamer »

Nope :(

It doesn't work.
I have try several codecs, I'm using Windows 7
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: PLay Movie Full Screen DirectX ???

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
JHPJHP
Addict
Addict
Posts: 2268
Joined: Sat Oct 09, 2010 3:47 am

Re: PLay Movie Full Screen DirectX ???

Post 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)

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
TI-994A
Addict
Addict
Posts: 2752
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PLay Movie Full Screen DirectX ???

Post 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. :)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: PLay Movie Full Screen DirectX ???

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
TI-994A
Addict
Addict
Posts: 2752
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PLay Movie Full Screen DirectX ???

Post 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
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: PLay Movie Full Screen DirectX ???

Post 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:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Re: PLay Movie Full Screen DirectX ???

Post 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
User avatar
TI-994A
Addict
Addict
Posts: 2752
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PLay Movie Full Screen DirectX ???

Post 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. :)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply