Should this Video Texture blend work?


I’ve scrutinised this plenty. It looks like it should
777.blend (815.9 KB)
work. The texture to be replaced shows but the video never plays. You will have to replace the video I used with your own as I can’t upload a huge video. Any help appreciated !

from bge import logic, texture

def play(cont):

    obj = cont.owner

    # the creation of the texture must be done once: save the
    # texture object in an attribute of bge.logic module makes it persistent
    if not hasattr(logic, 'video'):

        # put a material on the object, put the name of the material 
        # below. and at MA in front of the material name
        matID = texture.materialID(obj, 'MAplop')

        # create a dynamic texture that will replace the static texture = texture.Texture(obj, matID)
        # define a source of image for the texture, here a movie
        movie = logic.expandPath('//WiegelesHeliSki_DivXPlus_19Mbps.mkv') = texture.VideoFFmpeg(movie) = True

        # quick off the movie, but it wont play in the background

    # you need to call this function every frame to ensure update of the texture.

video_to_texture.blend (510.1 KB)


With this I get the error (UPBGE 3.0) …

**Error**: **Python**(**Cube**), Python script error
Traceback (most recent call last):
File "/Users/michaelzfreeman/Downloads/video_to_texture.blend/", line 16, in play
RuntimeError: Texture is not available
Blender Game Engine Finished

Ah 3.0, can’t help you here, i’m not using 0.3.0.

Fixed. (422.0 KB)

The primary issue was that your filepath code was incorrectly setup.

Thanks SO much for this. I was actually using code from the UPBGE docs on video textures so will be putting in a bug report to get THAT updated !