Should this Video Texture blend work?

Hi,

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
        logic.video = texture.Texture(obj, matID)
    
        # define a source of image for the texture, here a movie
        movie = logic.expandPath('//WiegelesHeliSki_DivXPlus_19Mbps.mkv')
        logic.video.source = texture.VideoFFmpeg(movie)
        logic.video.source.scale = True

        # quick off the movie, but it wont play in the background
        logic.video.source.play()

    # you need to call this function every frame to ensure update of the texture.
    logic.video.refresh(True)

video_to_texture.blend (510.1 KB)

Hi,

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/video.py", 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.

777.zip (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 !