- Home /
The byte stream type of the given URL is unsupported?
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.
It turns out, the "url" in this case actually refers to the file path (it might also work for web links, but the documentation for this is so poor, it hurts) so I resolved my issue by putting the video in a special reserved Unity folder called Strea$$anonymous$$gAssets and revised my code as such:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.Scene$$anonymous$$anagement;
using System;
public class CinematicControl : $$anonymous$$onoBehaviour
{
public Canvas canvas;
public VideoPlayer standalone; //standard player
private VideoPlayer myPlayer; //the player we're using
private bool paused;
public bool pauseUnfocus = true;
private bool ended = false;
int held = 1;
private void Awake()
{
paused = false;
myPlayer = standalone;
#if UNITY_WEBGL
myPlayer.url = Application.strea$$anonymous$$gAssetsPath + "/Cutscene – Gabe edit.mp4";
#endif
myPlayer.prepareCompleted += OnPrepared;
myPlayer.loopPointReached += OnEndReached;
myPlayer.Prepare();
}
Answer by HarshadK · May 15, 2017 at 01:23 PM
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.
@Harshad$$anonymous$$ Thanks for Replay. So how can i achieve this.i need to stream youtube video in Hololens with unity 5.6 videoplayer. please help
Your answer
Follow this Question
Related Questions
Video Player WebGl Transparency problem - previous frames doesn't clear 1 Answer
Using Video Player with URL in WebGL 0 Answers
Video don't play unity WebGL on URL 1 Answer
How to play video on WEBGL 0 Answers
VideoPlayer not playing in WebGL Build 0 Answers