VideoFFmpeg: materialID

materialID(obj, name)
  • Returns a numeric value that can be used in the Video Texture module to create a dynamic texture.

Return Type:

  • integer

obj:

  • The game object that holds the texture.
  • Type: KX_GameObject
     
name:
  • Name of the texture or material you want to make dynamic.
  • Type:  string
Note:
  • Material name must have MA prefix.
    Material must have an image in the first texture channel.
    If the material name is Canvas, you'd use "MACanvas"
     
  • Texture image name must have IM prefix.
    Texture image must be in the first texture channel.
    If the texture image name is Static.jpg, you'd use "IMStatic.jpg"
Sample Code

###################### get materialID

# 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 the 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()