Hi there, to play a video i am using the following code
self.tex = MovieTexture("name")
success = self.tex.read("A_CLIENT\ASSETS\GAME\CINEMATICS\intro.mp4")
assert success, "Failed to load video!"
# Set up a fullscreen card to set the video texture on.
cm = CardMaker("My Fullscreen Card")
# Tell the CardMaker to create texture coordinates that take into
# account the padding region of the texture.
# Now place the card in the scene graph and apply the texture to it.
card = NodePath(cm.generate())
self.sound = self.base.loader.loadSfx("A_CLIENT\ASSETS\GAME\CINEMATICS\intro.mp4")
# Synchronize the video to the sound.
but, how can i detect when it ends?
to make the function return only when the video is over, but this never ends, the last frame of the video stays on screen and the while loop never ends!
note: in the while loop self.sound.isPlaying raises an error.
Indeed: Outside of a more-advanced technique, the above will keep the code within that while-loop–and thus unable to do anything else (such as continue the video).
The approach shown by serega above should work, I daresay. As an alternative, you could perhaps do similarly, but combine it with your approach and within the task check the result of the “isPlaying” method. Something like this: