Executing through an order...

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()”.

Sounds like you’re looking for something like a Do-Later task, as described halfway down this page of the manual.

David

did you try Sequence?

Sequence(
               Func(playMyMovie),
               Wait(0.6),
               Func(loadMyNextModule)
               ).start()

def loadMyNextModule():
      Stage()

hope it helps you

from direct.interval.IntervalGlobal import *

panda3d.org/manual/index.php/S … _Parallels
panda3d.org/apiref.php?page=Sequence

dvd : the code above works, i must to say all codes here works and call the next module, but when it executes the next module, print the error in run() line of the next code. (in this case, stage0.py). so i can believe that functions are working, but something does not let the stage0.py module execute after the video…

zephyro:
yes, i guess intervals too, you answered too fast, well… i tried that and got the same trouble message that before… the assertionerror

mport direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *
from direct.task import Task

class Video(DirectObject):
	
	def __init__(self):
	
		#base.disableMouse()
		base.setBackgroundColor(0,0,0)

		Sequence(Func(self._loadVideo), Wait(0.6), Func(self._loadGame)).start()
		
				
			
	def _loadVideo(self):
		animPlane = loader.loadModel("../intro_media/animation")
		animPlane.reparentTo(render)
		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.setLoop(False)
		self.aviMovie.play()
		
		bgm = loader.loadSfx("../intro_media/bgm.mp3")
		bgm.play()
		
		
	def _loadGame(self):
		import stage0
		Stage0()
	
v = Video()
run()

this system prints:

AssertionError: _num_busy_threads == 0 at line 865 of c:\p\p3d\panda3d-1.6.2\panda\src\event\asyncTaskChain.cxx

:unamused:

if Stage0() is a class or function of the module stage0, try this:

import stage0
stage0.Stage0()

That error message means you tried to call taskMgr.step() or taskMgr.run() from a function that was itself called from a task. Is your Stage0 function trying to run its own task loop? If so, you can’t call it from an interval (which is run within a task). But maybe there’s no need for it to do so.

David

Thanks again for answering… tried removing tasks and the stage0.stage0() line, and could not get work… but i starting to think this could be a python bug… because this :

this next code works perfectly : (skipping the movie lines)

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject

class Video(DirectObject):

     def __init__(self):
          
               
          import Stage0
          Stage0.Stage0()

v = Video()
run()

But this one has the problem of assertionError:

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject

class Video(DirectObject):

     def __init__(self):

          
          self.accept("a", self.nextModule)



     def nextModule(self):

          import Stage0
          Stage0.Stage0()

v = Video()
run()

Weird… works directly without calling a function, but in the second code if i press A, i got the error… maybe a python bug?, and i say python bug because is a simple call to a function, the difference is really insignificant.

personally think, the movie lines are ok, the ways to wait the video finish you proposed before are good and work, but if we reduce the code to the difference between both above codes, we could finish thinking python’s bug…

what do you think…_?

I forgot to mention that i tested this code (with or without the movie lines call) , not importing Stage0 else some samples of the panda samples library (renaming the module names to a simple name), and the same…

Got it !!!.. was a very novice fool error from my part… was executing las two lines ( v = Video(), run() and s = Stage0(), run() ) in the two first modules respectively… when just only the first one must to execute…

thank you for answering…