Strange Movie problem

Just starting out? Need help? Post your questions and find answers here.
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Strange Movie problem

Post by kenmo »

When I load and play a movie (video) in a window, it literally wont show up. However if I move the window, it appears and continues to play normally. Does this happen to anyone else? Just try the "Movie" example code and see if it does it. If it isnt just me, is there a solution?

Not a big problem, its just annoying, especially if you want to release a media player and the user has to move the window whenever they play a file...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Strange Movie problem

Post by PB »

I have the same problem, and solved it by opening an invisible window,
starting the movie, then showing the window. Add this flag to your
OpenWindow command: #PB_Window_Invisible. Then, use the
PlayMovie(0,WindowID()) command, followed by this API
command: ShowWindow_(WindowID(),#SW_SHOW).

(I still think this is a bug, as I have the latest GeForce video drivers and
Service Pack for Windows 2000 Professional).
Bong-Mong
User
User
Posts: 35
Joined: Sat Jan 03, 2004 6:53 pm

Post by Bong-Mong »

playmovie()
Delay(500)
Resizewindow(#window_0,-1,-1,size,size)

works for me
1.3AMD, 2x 256 sdr, 32 AGP
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Neither of those works for me

Are you playing MPGs? I think only MPGs are officially supported (not AVI
and other video formats). If so, does this work for you? Does for me...

Code: Select all

m$="c:\MyMovie.mpg"
If OpenWindow(0,0,0,352,240,#PB_Window_Invisible|#PB_Window_ScreenCentered,"test")
  InitMovie() : LoadMovie(0,m$) : PlayMovie(0,WindowID()) : ShowWindow_(WindowID(),#SW_SHOW)
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
(Note to Fred/Webmaster: Why is this reply above Kenmo's?).
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Neither of those works for me. It doesnt really matter, because I didnt plan on releasing my current program... so oh well.
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

PB wrote:(Note to Fred/Webmaster: Why is this reply above Kenmo's?).
Thats pretty weird...

Yes Im using MPGs and yes that code works... however my app doesnt just automatically open a movie and play it, you have to choose load and open it. Which means the window has to be visible before I play the movie. Maybe if I used showwindow_() and set it invisible right before I play it, then showwindow_() it back to visible after? Is there a constant for #SW_HIDE or something?

edit - aha, it is #SW_HIDE and it does work. Thank you!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Making the window go invisible and then visible again will work, but it will
make your window lose its place on the Taskbar (which makes your app
look unprofessional). So, try the following instead:

Code: Select all

m$="C:\MyMovie.mpg"
If OpenWindow(0,0,0,352,240,#PB_Window_ScreenCentered,"Press SPACE to 'load' movie")
  Repeat : Sleep_(1) : WindowEvent() : Until GetAsyncKeyState_(#VK_SPACE)<>0
  InitMovie() : LoadMovie(0,m$) : PlayMovie(0,WindowID())
  RedrawWindow_(WindowID(),0,0,#RDW_INVALIDATE) ; Update window.
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Ahh thank you that is easier and works so much better!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I still have this problem as of today (Mar 17, 2007) with PB v4.02, so there's
still a bug or something going on here. Even redrawing the window or using
API calls doesn't always fix it. Resizing the window is reportedly the fix, but
this isn't elegant, nor is it an acceptable long-term solution.

Also, sometimes during movie playback, the movie will just go blank again,
requiring me to move the window to redraw it. So I'm not sure if it's my PC
due to Media Player 11, or the PureBasic PlayMovie command, or what?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

What happens if you disable all video accelleration or boot in safe mode? Is there still a problem?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> What happens if you disable all video accelleration

Hi Trond, yes, it works if I stave off the video acceleration a bit. If I use the
setting below, then all works as expected with no problems. So hopefully
that means it's not a PureBasic problem, but I'm not sure because it seems
to be DirectX related? Normally I have acceleration set to full and have no
display problems with any other apps, so PureBasic is the odd one out.

Image
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Then it sounds like a driver problem.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

That only affects PureBasic? ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
codefire
User
User
Posts: 38
Joined: Thu Mar 15, 2007 4:32 pm
Location: UK

Post by codefire »

I get the same problem.

It seems almost like the screen is not getting the initial redraw command.

However, when you drag the window it seems to initiate a Windows redraw command, the window is refreshed and it seems OK from that point on.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

PB wrote:That only affects PureBasic? ;)
Well, I have a different driver, but the same PureBasic, and then it works.
Post Reply