bge.texture.VideoFFmpeg() how to set the previous image back?

Hi,

Texture, materials , UV and stuff is really the thing im noob with. … :confused:
How can i set my image material back once i played a video ? My video plays fine but once it’s finish, it sticks to the last frame of the video and doesnt put the image texture back …

        matID = bge.texture.materialID(obj, "MADisplay")
        video = bge.texture.Texture(obj, matID)
        movieName = "video.avi"
        movie = bge.logic.expandPath('//' + movieName)
        video.source = bge.texture.VideoFFmpeg(movie)

Its the same as if you were replacing a static texture, you can just delete the new texture and the old one will return. Described in the API Reference example:

def removeTexture(cont):
    """ Delete the Dynamic Texture, reversing back the final to its original state. """
    try:
        del logic.texture
    except:
        pass

Of course in your code your texture is called ‘video’ so you would change the delete line to:
del video

This only works if you still have access to ‘video’ which is why you need to save a reference to it. And having access to it allows you to check the status of the source.
video.source.status should return -1 through 3 depending on what its currently doing.

-1 = bge.texture.SOURCE_ERROR
0 = bge.texture.SOURCE_EMPTY
1 = bge.texture.SOURCE_READY
2 = bge.texture.SOURCE_PLAYING
3 = bge.texture.SOURCE_STOPPED

If the status is 3, the video is stopped so you can delete your video texture and return the old texture. Just make sure your code knows what to do after deleting it (for example you can turn off positive pulse mode, load a new video, shut down the interface, etc.).

thank you.

But it seems that all it does, it’s freezing the video on the running frame. Can you make a full example if you can ? :woozy_face:

Hopefully this works.
vid_texture_demo.zip (2.9 MB)

1 Like

Thank you very much. It works. I will just add now system to pause, resume and stop :slight_smile:

1 Like