MovieTexture... finished playing?

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)
     MyMovieCard = CardMaker("My Full Screen Card")
     MyMovieNode = NodePath(MyMovieCard.generate())

def mytask(task):
     global MyMovieTexture
     global MyMovieNode
     if MyMovieTexture.isPlaying() == False:
     return Task.cont

taskMgr.add(mytask, "MainMenuLoader")

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

Interesting. I’m a little surprised that isPlaying is returning 1.

For now, you can use movie.getTime() >= movie.getLength() as a temporary workaround.

First of all, thx for the reply. Now i tried the getLength() method but it seems that it doesnt apply for any kind of movie class, thus my game crashes with “object has no attribute” if i try it. Corrupt Panda Installation maybe?

It may work in another version, i dont know, im using Panda 1.4.2 and Python 2.4, so if thats the case, plz let me know. XD

Anyway, I have been looking around and MovieVideoCursor seems to support some length() thing, i have been trynig to get it to work, but no luck yet.

Supposedly i need a MovieVideo, and a Filename, so i tried this:

from pandac.PandaModules import MovieVideoCursor
from pandac.PandaModules import MovieVideo
from pandac.PandaModules import Filename

myFileName = Filename("mymoviefile.avi")

print myFileName.getFileSize()
#returns the file size correctly
#so the problem shouldnt be here... i think

myMovieVideo = MovieVideo("My Movie Video")

print myMovieVideo.getFilename()
#returns a blank line which makes me wonder
#if the problem is really the filename
#or how i assigned it

myMovieVideoCursor =
#seems to give the same result as using:
#myMovieVideoCursor = MovieVideoCursor(myMovieVideo)

print myMovieVideoCursor.length()
#returns 10000000000.0
#which is clearly wrong

Im clearly doing something wrong, but im clueless, that or the code is broken (less probable, i hope). I also tried to export my .avi into different formats (even raw video) to avoid any length misreading, but the result was the same.


doh! i found out that i was still using Panda 1.4.0 in py2exe instead of 1.4.2, the py2exe problem is solved now.

The setLoop function doesn’t exist at all.
And, your object is an FFMpegTexture and a MovieTexture at the same time, since FFMpegTexture also inherits from MovieTexture. None of the things it inherits, has a setLoop function.

Thx for the quick reply =D

doh! i found out that i was still using Panda 1.4.0 in py2exe instead of 1.4.2, the py2exe problem is solved now

Hey guys, i found something by accident, some kind of bug, that could as well solve this issue:

When we have just loaded a MovieTexture

myMovieTexture = loader.loadTexture("myMovieFile.avi")

The MovieTexture automatically starts playing an infinite loop (yes we all know this). So when its a one time run movie we usually immediatly add


in order to make it run only once. Then we can call a getTime() that will correctly return how our movie advances in time. HOWEVER if we call a getTime() when the movie is looping, it will always return the LENGTH of our movie, for instance, if we got a 3.25 seconds long movie:

myMovieTexture = loader.loadTexture("myMovieFile.avi")
print myMovieTexture.getTime() #returns 3.25
print myMovieTexture.getTime() #returns 0.0

So as the movie is considered to be playing and looping right after we load it, we could exploit it like this:

myMovieTexture = loader.loadTexture("myMovieFile.avi")
myMovieLength = myMovieTexture.getTime()

def myTask(task):
     if myMovieTexture.getTime() == myMovieLenght:
     return Task.cont

taskMgr.add(myTask, "Task")

Although this looks like a good workaround, i would still like to check for a less buggy solution.

Actually i just found out that isPlaying() works correctly with AnimInterface when we use VideoTextures, but it doesnt work properly with MovieTextures.