About WebGLMovieTexture with UI elements

Hello @jonas-echterhoff_1 and the rest of this commUnity

I’m using the plugin WebGLMovieTexture, (created by @jonas-echterhoff_1 is excellent, thank you.)

But I need to know if is possible to use this in a UI element, like a Raw Image, simple Image, Panel, and how?

bool jugo = false;

WebGLMovieTexture m;
void Start () {
if (ApplicationModel.way == “0” && ApplicationModel.videostep == “0”)
{
m = new WebGLMovieTexture(“StreamingAssets/Draft_1.mp4”);
RawImage gt = GameObject.Find(“videosToPlay”).GetComponent();
gt.texture = m
}
}

void Update () {
m.Update();
if (m.isReady && !jugo)
{
m.Play();
jugo = true;
}
if (jugo)
{
//next
if (m.time == m.duration)
{
ApplicationModel.videostep = “1”;
jugo = false;
}
}
}

All that I can see is a black square.

Can help me somebody?

Yes just set the Material.mainTexture instead of the texture itself.

GetComponent<RawImage>().material.mainTexture = tex;

Happy Coding

Hey! That didn’t work for me (the video is not displayed)… I do listen to the video’s audio, though. Notice that the example scene is working for me (rendering the video on a cube), it’s only the RawImage the one that doesn’t display anything.

Can you repost your code, I’ll happily take a look at it.

Oh, nothing fancy: I just create the texture like this…

m_WebMovieTexture = new WebGLMovieTexture("StreamingAssets/" + m_MoviePaths[m_CurrentVideoIndex]);
m_Image.material.mainTexture = m_WebMovieTexture;

And then I check if the texture is ready to play in an Update:

if (!m_PlaybackStarted && m_WebMovieTexture.isReady)
{
     m_WebMovieTexture.Play();
     m_PlaybackStarted = true;
}

When running in the web browser, I hear the video’s audio track, but don’t see anything on the RawImage (except the color I’ve already set on it).

EDIT: I’ve tried using “m_Image.texture” before, but that didn’t work (it did work with the standard MovieTexture, of course)

Hello @Anibal_Hormeche I’m in the same situation, you can find a solution?

I can get mine to play, but if i change to another video URL, it keeps streaming the old video, so now i have two internet streams.

Anybody knows how to delete and remove an instance of the WebGLMovieTexture, or to make it start playing from a different URL?

Seems its impossible to delete it and make a new one to play a different video, and the API only creates new ones if you want to play a different video, so the old ones are still sitting in memory streaming video from the internet.