VideoFFmpeg: pause

pause()
  • Pauses the video.
Note:
  • Use play() to unpause video.
Sample Code: Part 1

###################### play the video

# import bge module
import bge

# get the current scene
scene = bge.logic.getCurrentScene()

# get list of objects in scene
objList = scene.objects

# get object named MovieScreen
obj = objList["MovieScreen"]

# check to see if Video FFmpeg Texture was saved as an object variable
# in other words, was the movie started

if "Video" in obj:  

# get the saved object variable
video = obj["Video"]
  
# update the video texture
video.refresh(True)

else:
 
# get matID for the movie screen
# my material is named Display
matID = bge.texture.materialID(obj, "MADisplay")
   
# get the video texture
video = bge.texture.Texture(obj, matID)
      
# get the name of the movie
movieName = "BigBuckBunny.ogg"
      
# get movie path
# movie is in same directory as blend
movie = bge.logic.expandPath('//' + movieName)
      
# get video texture source
video.source = bge.texture.VideoFFmpeg(movie)
      
# save video texture as an object variable
obj["Video"] = video
   
# start the video
video.source.play()
 
Sample Code: Part 2

###################### Pause/Resume the video

# import bge module
import bge

# get the current controller
controller = bge.logic.getCurrentController()

# get list of sensors
senList = controller.sensors

# get keyboard sensors used to pause/resume video
# my pause sensor is named "Pause"
# my resume sensor is named "Resume"
pause_sensor = senList["Pause"]
resume_sensor = senList["Resume"]

# get the current scene
scene = bge.logic.getCurrentScene()

# get list of objects in scene
objList = scene.objects

# get object named MovieScreen
obj = objList["MovieScreen"]

# get the saved video texture
video = obj["Video"]

# pause video
if pause_sensor.positive == True:  

# pause the video
video.source.pause()

# resume video
if resume_sensor.positive == True:
 
# resume the video
video.source.play()