After get movie works thanks to dvd, i would like to initialize the next module after the movie finished.
The idea is to load the next module containing the game menu after the video presentation, but only after video finished, not before…
Trying different syntax, i looked into manual the attribute “movie.getTime()”, my video’s time is 6.0 seconds exactly, i expected to write a while or if, like this:
while (movie.getTime() == 6):
import Stage0
Stage0()
or replacing while to if. the same result.
but problem is that the call of movie.getTime is just one time, so, the first time and the only is the first, 0.0 seconds.
Well, i was thinking in tasks, and tried to do a task:
class Video(DirectObject):
def __init__(self):
#base.disableMouse()
base.setBackgroundColor(0,0,0)
animPlane = loader.loadModel("../intro_media/animation")
animPlane.reparentTo(render2d)
animPlane.setScale(1.5, 1, 2)
animPlane.setPos(0, 0, 0.3)
self.aviMovie = loader.loadTexture("../intro_media/intro.avi")
animPlane.setTexture(self.aviMovie, 1)
self.aviMovie.setPlayRate(1)
self.aviMovie.setLoop(False)
self.aviMovie.play()
bgm = loader.loadSfx("../intro_media/bgm.mp3")
bgm.setVolume(1)
bgm.play()
taskMgr.add(self._detectTime, "DetectMovieTime")
def _detectTime(self, task):
if (self.aviMovie.getTime() == 6):
self._loadGame()
return Task.done
if (self.aviMovie.getTime() < 6):
print "Not yet"
return Task.cont
def _loadGame(self):
import stage0
Stage0()
v = Video()
run()
But in execution, i got the message:
File "C:\SkyCastle\ProjectA\data\startGame.py", line 35, in _detectTime
self._loadGame()
File "C:\SkyCastle\ProjectA\data\startGame.py", line 44, in _loadGame
import stage0
File "C:\SkyCastle\ProjectA\data\stage0.py", line 64, in <module>
run()
File "C:\SkyCastle\Panda3D\direct\showbase\ShowBase.py", line 2423, in run
self.taskMgr.run()
File "C:\SkyCastle\Panda3D\direct\task\TaskNew.py", line 471, in run
self.step()
File "C:\SkyCastle\Panda3D\direct\task\TaskNew.py", line 429, in step
self.mgr.poll()
AssertionError: _num_busy_threads == 0 at line 865 of c:\p\p3d\panda3d-1.6.2\panda\src\event\asyncTaskChain.cxx
Is there a way to wait video plays all frames, and then execute the next module?
I forgot to tell you i proved calling a method that contains the import of the next module, calling this method in init, was without the (), in theory, the line “self._callMethod” will not execute instantly, not like that “self._callMethod()”.