Getting WebGL to play videos

Hello everyone! I was hoping I could get some help with something really important.

I have a game that I made and the way my game works is that video clips play and the player clicks buttons to navigate to the next scene. My videos are set up as MovieTextures, which work fine on the EXE build. However, I am going to need it on a WebGL build and I know MovieTextures don’t work with WebGL. I know I can switch my videos to VideoClip, which I did before, but the WebGL build never worked (it never played the video in the scene).

I’m kind of lost on what to do here. My game will need to go on a website eventually and unless there is a way to get an EXE to work on a website, I am not sure what to do.

Any help would be appreciated.

Please let me know if you have any other questions. Thanks!

Use the Video Player component instead. Set it to use a URL and fill in the absolute URL to the video.

How do I make it an absolute path on my computer? Or is there a way to get an online URL working? I tried using a Youtube video of mine but the URL didn’t work for some reason.

You have to host it yourself, just like your webGL build you have to host it somewhere.
Youtube video’s don’t work with the Video Player component of Unity, because they are not an absolute path to a file. So for that you will need an asset from the asset store.

Would that be the StreamingAssets plugin?

Okay, so I got it to play from a URL, which is a file path to where the video is on my computer, but when I export it, it still doesn’t play the video.

Make sure it is an mp4 with h.264 encoding

I am exporting from After Effects. Does the preset of it matter? Or do I just need to make sure it’s an mp4 with h.264 encoding?

I’d say just test a few small fragments so you don’t have to wait too long to see if it works.
I don’t know any more specifics than it needing to be a .mp4 with h.264 encoding.

It didn’t work.

Is there a specific code I have to write in order to get it work on export? I read in some documentations that there’s some code for streaming assets that goes like this:
path = Application.dataPath + “/StreamingAssets”;
Do I have to put that somewhere in my code?

Like I said you need an absolute path. How you insert that in the video player url variable is up to you.
You can serialize it or set it via script
I don’t know out of mind if the Application.StreamingAssetsPath works in webgl. You’d have to test that…
Just debug log the path and look it up in the console.

If you have a server that is hosting the webgl build you probably end up with something like

www.server.com/builds/webgl/streamingassets/MyVideo.mp4

Where www.server.com/builds/webgl/streamingassets is returned by Application.StreamingAssetsPath.

Like I said, don’t know out of mind. Test it.
Simple empty scene with a script that does some debugs and sets the video url and starts it is all you need.

Okay, I’ll see what I can do.

I’m honestly not sure how to set it up via script since I am not really a programmer. Using a file path from my computer is all I really know.

Also not entirely sure how to set up the debug log to test this specific issue.

Youtube video’s don’t work with the Video Player component of Unity

Is there a way to host it on a website and get the video to play from there?

Hey guys. I’m still having trouble getting it to work. Can someone show me an example of a working URL that will play in both the editor AND the Web GL export?

Is there any code I have to attach to this in order for it to work?

Is there a place I can host the videos and test it out to see if it works?

I’m tryna figure this out too any luck?