I’m trying to implement video for WebGL. Since mp4 files are unsupported I’m making an exception for WebGL; trying to use a link instead:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.SceneManagement;
public class CinematicControl : MonoBehaviour
{
public Canvas canvas;
public VideoPlayer vp; //standard player
public VideoPlayer web; //one that uses a link
private VideoPlayer myPlayer; //the player we're using
int held = 0;
// Use this for initialization
void Start ()
{
#if UNITY_WEBGL
myPlayer = web;
#else
myPlayer = vp;
}
However, when I build for WebGL I get the error: The byte stream type of the given URL is unsupported.
Does anyone know what the issue is? I’m using a generic YouTube video for testing purposes.
A little late to the party but since @AnkitSangani has revived this question. Here are some details about why the error The byte stream type of the given URL is unsupported
is thrown when using YouTube video url.
Firstly it is important to understand how YouTube plays videos. This article explains it pretty good. Now in order to get the actual byte array stream of video you need to use the videoplayback url (which looks like: videoplayback?..) which makes call to get the byte stream. Now if you inspect the requests to this URL using the developer tools in browser you can see the response received by the request. The response headers include the content-type to be content-type:video/webm
or content-type:audio/webm
based on whether it is video file request or audio file request. This shows that the type of byte stream returned if of webm
file format type which is decoded using a VP9 decoder which Unity does not support. Hence the error. If you use a URL which returns a video file format supported by Unity then you would be able to play it.