Hi, i have recently added some intro movie to my game, when the movie is done playing it should then load the Main Menu, however i havent figured a simple way of letting panda know when the movie has finished.
My code looks something like this:
...
...
def MainMenu():
...
def mymovie(moviefile):
global MyMovieTexture
global MyMovieNode
MyMovieTexture = loader.loadTexture(moviefile)
MyMovieTexture.setLoop(False)
MyMovieTexture.play()
MyMovieCard = CardMaker("My Full Screen Card")
MyMovieCard.setFrameFullscreenQuad()
MyMovieCard.setUvRange(MyMovieTexture)
MyMovieNode = NodePath(MyMovieCard.generate())
MyMovieNode.reparentTo(render2d)
MyMovieNode.setTexture(MyMovieTexture)
def mytask(task):
global MyMovieTexture
global MyMovieNode
if MyMovieTexture.isPlaying() == False:
MainMenu()
MyMovieNode.removeNode()
taskMgr.remove("MainMenuLoader")
return Task.cont
mymovie("mymoviefile.avi")
taskMgr.add(mytask, "MainMenuLoader")
run()
So the movie plays correctly once, and it apparently stops. If i add a:
print MyMovieTexture.getTime()
to mytask it correctly displays how the time increases, untill it continuosly prints 3.25 (which is my current movie length… well more like just a logo now XP ). However:
print MyMovieTexture.isPlaying()
will always return 1, even when the movie is finished, unless i explicitly stop() it with another function.
I have improvised a workaround for now, i would use:
if MyMovieTexture.getTime() == 3.25 #instead of isPlaying() == False
But it is very unpractical, since i keep increasing the length of my movie, and i plan on using similar functions (or those) to play the rest of my game movies(which are very unlikely to have the same length, and that would mean adding a lot of "if"s XD).
I thought of using some task that detects when the movie cursor is stuck at the same time over and over, but i was wondering if i had missed some method or property or so that could tell me either the total lenght of a movie or if it has finished playing, even if that means playing the movie in a different way, other than movietexture. If not, do you know any third party package that supports this? pygame or so? Don’t worry, i would still use panda for the 3d engine XP.
BTW im using Panda3D 1.4.2 and Python 2.4