Video Player on WebGL

Hey everyone

I have this project I’ve been trying to upload to Itch.io with a WebGL build but when the build includes 4 of the videos that playing during the project, itch says the file is too large and can’t be uploaded though I have compressed them already but does anyone have any tips on how to perfect this?

Additionally, a lot of the threads I have found said that video player doesn’t even work while running on WebGL. Is there a way to get around this?

The project is a virtual art exhibition so the videos can’t be removed from the show.

I’m fairly new to using unity and even these forums so apologies if there isn’t enough information

Hey - the only way I got videos in WebGL to work is by pointing the video player in the Unity API to an URL instead of building the video files into the project. Your file will be smaller without the videos included, but you will need to find hosting for the videos somewhere.

Also there are a bunch of issues with videoplay in WebGL - this video helped me get it to work:

Also, video playing on startup can be a problem as a lot of browsers block autoplay - a simple way around this is to make some sort of “play” button, as the browser will allow autoplay once the user has interacted with the page.

2 Likes

Does anyone know of a preferably free site that will host videos and support a direct link to them so that I can have video in my WebGL project? I hate to be cheap, but right now I just want to host a couple of small videos for learning purposes only. If there’s nothing free, can you recommend a reasonably priced, easy to use alternative? Thanks!

Hey sorry for the late answer, but you can simply use youtube to host your video. If you don’t want the video to show up on your channel, just set them to unlisted.

YouTube links are not direct, they do not work in unity

2 Likes

I know it’s been a while, but you actually can stream YouTube videos with the VideoPlayer component. Check out this GitHub repository. WebGL is not supported due to CORS, however.

Hi there,

You can try using the “Video Player for WebGL” asset available on the Unity Asset Store. This asset is known for enabling smooth video playback for WebGL builds.

You might consider optimizing the videos further to reduce their file size. Tools like HandBrake or FFmpeg can help you compress videos without compromising too much on quality.
For video hosting Cloudinary is an option, but there are many other options.

Keep coding!

Additionally, a lot of the threads I have found said that video player doesn’t even work while running on WebGL. Is there a way to get around this?

Unity’s default video player has issues playing videos on browsers running on Apple devices. In addition, because Unity has to make a component that works for many build targets, it can’t specialize on features that are present just on one target.

Video Player WebGL is a plugin I made to address the issues above. It aims to bring all the video web features it can to Unity and work flawlessly across different browsers.

Just a note @Marks4 ; prf.hn links don’t seem to work. Better linking directly to the asset.

1 Like

there’s also this hacky method:

1 Like