Webgl unity build won't play Video

Jz Konain picture Jz Konain · Feb 24, 2019 · Viewed 12.3k times · Source

I have used video player to play video, everything works fine in unity but when I build it and run on firefox or any other browser,the video won't play. I have tried different settings and different video formats but nothing seems to work. I don't get any errors.

I have an empty scene with camera and video player, no scripts. Just used video player and used play on awake to play the video. Works fine in playmode but won't work in webgl build.

Answer

Jz Konain picture Jz Konain · Mar 5, 2019

In the editor create a folder with the name StreamingAssets and put your video files into that folder. The video format that I used is mp4 . Create a VideoPlayer component and attach it to a gameobject. Reference that component in a script and use the following command

videoPlayer.url = System.IO.Path.Combine (Application.streamingAssetsPath,"myFile.mp4"); 

You can use other videoplayer commands like Video.Play(); to play the video.