Video didnt play on browser but play correctly on unity editor


#1

hello, can someone help me with problem on displaying video on browser, im using unity videoplayer and render it on a plane, but when i try on browser and scan the marker only plane displayed with no video playing, any solution?


#2

Hi @salmanwizz,

Unfortunately this is more of a Unity based question rather than a ZapWorks SDK issue.

After having a look around Unity forum threads it looks like the solution might be to host the video and stream it in via the URL it’s hosted on.

A user has reported that streaming using the snippet below has worked for Unity 2019.4.4 and Google Chrome.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class PlayVideoInWebGL : MonoBehaviour
{
    [SerializeField]
    private VideoPlayer videoPlayer;
    [SerializeField]
    private string videoFileName;
    // Start is called before the first frame update
    void Start()
    {
        videoPlayer.url = System.IO.Path.Combine(Application.streamingAssetsPath, videoFileName);
        Debug.Log(videoPlayer.url);
        videoPlayer.Play();
    }
}

https://forum.unity.com/threads/new-unity-video-player-in-webgl.480383/

I’ve also found a note on their issue tracker which explains that the they’ve fixed video for WebGL in recent versions, however, looking at some of the user comments, it might still be broken.

Hope this helps.

George