playmovie drives me crazy :'(

Just starting out? Need help? Post your questions and find answers here.
salutcava
User
User
Posts: 10
Joined: Fri May 03, 2013 10:50 am

playmovie drives me crazy :'(

Post by salutcava »

Hello :'(
I copy/paste the movie.pb example from the official documentation...
When i F5 it doesnt work...ok ok....(doesnt work = sound ok but no video)
I open a new tab (ctrl+N) it doesnt work either...ok...ok...(sound ok but no video)
I open another tab (CTRL+N) it works (sound ok and video ok)

it's incredible...i think i will have to do a video capture of this since no one will belive me...

i'm using PB 5.72(x86) on Win10 x64
I must say that some days ago my computer switched off brutally, so i reinstalled PB to be sure that the crash isnt the source of the issue

The code i use (from the documentation) :

Code: Select all


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

MovieName$ = "Sigma.mp4"   ; i edited this line
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 

Maybe a config file i must delete? Please help :'(
BarryG
Addict
Addict
Posts: 3266
Joined: Thu Apr 18, 2019 8:17 am

Re: playmovie drives me crazy :'(

Post by BarryG »

Sounds more like your PC (corrupt video drivers) or the video itself is the problem. Have you tried other videos, and other videos after rebooting your PC?

What happens if you move the window a few pixels after the video starts playing? Does it work then?

The example code you posted is 100% perfect, so it's not a PureBasic bug.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: playmovie drives me crazy :'(

Post by JHPJHP »

Hi salutcava,

I had a similar problem that may or may not be related; try the following Registry hack:

Code: Select all

If InitMovie() = 0
  MessageRequester("Error", "Can't initialize movie playback !", 0)
  End
EndIf
lpSubKey.s = "SOFTWARE\Microsoft\Direct3D\Shims\EnableOverlays"
lpValueName.s = ProgramFilename() : lpData = 1

If RegCreateKeyEx_(#HKEY_CURRENT_USER, lpSubKey, 0, #Null, #REG_OPTION_VOLATILE, #KEY_SET_VALUE, #Null, @phkResult, @lpdwDisposition) = #ERROR_SUCCESS
  RegSetValueEx_(phkResult, lpValueName, 0, #REG_DWORD, @lpData, SizeOf(LONG))
  RegCloseKey_(phkResult)
EndIf

MovieName$ = "D:\PureBasic\OpenCV_2.4.13.6_WIN_32_SRC_(main)\binaries\videos\ball.mp4"   ; i edited this line
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

If RegOpenKeyEx_(#HKEY_CURRENT_USER, lpSubKey, 0, #KEY_SET_VALUE, @phkResult) = #ERROR_SUCCESS
  RegDeleteValue_(phkResult, @lpValueName)
  RegCloseKey_(phkResult)
EndIf
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 617
Joined: Mon May 09, 2011 9:36 am

Re: playmovie drives me crazy :'(

Post by VB6_to_PBx »

Windows: as it uses the DirectX technology (DirectShow), any kind of media can be played with this library: AVI, MPG, DivX, etc.
can you Play a .MP4 Movie with PureBasic MoviePlayer code ??

MovieName$ = "Sigma.mp4" ; i edited this line
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
salutcava
User
User
Posts: 10
Joined: Fri May 03, 2013 10:50 am

Re: playmovie drives me crazy :'(

Post by salutcava »

-Hello BarryG, thx for your answer :')
Other video were working ok, after rebooting the PC
Using ResizeMovie was unsuccessful :(
I agree, the code is 100% perfect :(

-Hello JHPJHP, thanks for your answer.
You rock. Actually the RegKey was already set before i start your code, so i changed lpdata value from 1 to 0
AND NOW IT WORKS ! You rock !! Thx a lot !

-Hello VB6_to_PBx, thanks for your answer too.
Yes a MP4 can surely be played by movieplay on windows.

Thanks to you three for your answers, now it's fixed with the regkey from JHPJHP.
Issue solved ! You are genius!
BarryG
Addict
Addict
Posts: 3266
Joined: Thu Apr 18, 2019 8:17 am

Re: playmovie drives me crazy :'(

Post by BarryG »

salutcava wrote:Using ResizeMovie was unsuccessful
I meant you moving its window with your mouse (manually). Sometimes that makes a video start displaying properly. But we won't know now, because of the RegKey fix.
salutcava wrote:the RegKey was already set before i start your code, so i changed lpdata value from 1 to 0
AND NOW IT WORKS ! You rock !! Thx a lot !
Interesting! Will have to remember that for future reference.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: playmovie drives me crazy :'(

Post by chris319 »

It seems to help if ResizeMovie() is called after the window is opened and after PlayMovie() is called.

Don't forget to call FreeMovie() when finished.
novablue
Enthusiast
Enthusiast
Posts: 165
Joined: Sun Nov 27, 2016 6:38 am

Re: playmovie drives me crazy :'(

Post by novablue »

Hello i had the same problem using mci on windows 10, now i found out the same thing happens with the build in movie commands. The registry solution works for me sometimes. the solution i found for mci also fixes the movie commands in a more reliable way at least on my systems.

quote from the other thread that also applies to the movie lib:
I found a strange workaround now. It only fails to load the first video. in this case Film1 is always failing and stays blank, the rest, Film2 and 3 will play fine as long as i don't close the first handle to Film1. It also works with just the open command without playing Film1. Any idea what this strange behavior could be?

Code: Select all

InitMovie()

#Film1 = 0
#Film2 = 1
#Film3 = 2

MovieName$ = OpenFileRequester("Choose the movie to play", "", "Movie files|*.avi;*.mpg;*.mp4|All Files|*.*", 0)
If MovieName$
	LoadMovie(#Film1, MovieName$) ; dummy video to fix future videos
	
	OpenWindow(0, 100, 150, MovieWidth(#Film1), MovieHeight(#Film1), "PureBasic - Movie")
	
	PlayMovie(#Film1, WindowID(0)) ; Broken! will play a Blank video, the following videos also work with this line commented out
	;FreeMovie(#Film1) ; If i close here Film2 won't work either and only Film3 will play, otherwise both work
	
	LoadMovie(#Film2, MovieName$)
	PlayMovie(#Film2, WindowID(0))  ; Plays Fine
	
	LoadMovie(#Film3, MovieName$)
	PlayMovie(#Film3, WindowID(0))  ; Plays Fine
	ResizeMovie(#Film3, 0, 0, 100, 100)
    
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf 
one more note: Film1,2,3 don't have to be the same file, it can be 3 different video files and it will still work.
Post Reply