- Home /
WWW.movie never get ready to play ?
Hello there,
I'm trying to stream a movie from an external directory (on a distant server or on my computer). While I have no trouble retrieving the whole video, I can never get it to play because isReadyToPlay is always false.
At first, I thought it was a codec issue but it can't be it. When I import it in my project, it is not converted (since it's already OGG Theora) and it plays well.
Here's the slightly modified test code I found on the net :
#define STREAMING
using System;
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class VideoStreamer : MonoBehaviour
{
public MovieTexture movieTexture;
protected bool streamReady = false;
void Start ()
{
#if STREAMING
StartCoroutine(StartStream(@"C:\Users\mparent\Videos\teaser_ANTITRUST_FR_1.ogv"));
#else
audio.clip = movieTexture.audioClip;
audio.Play();
movieTexture.Play();
#endif
}
#if STREAMING
protected IEnumerator StartStream (String url)
{
WWW videoStreamer = new WWW (url);
movieTexture = videoStreamer.movie;
audio.clip = movieTexture.audioClip;
while (!movieTexture.isReadyToPlay) {
if ( ! videoStreamer.isDone ) Debug.Log ( "Downloading !");
else Debug.Log ( "Preparing stuff...");
yield return 0;
}
Debug.Log("Start playback");
audio.Play ();
movieTexture.Play ();
streamReady = true;
}
#endif
void OnGUI ()
{
#if STREAMING
if (streamReady) {
GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), movieTexture);
}
#else
GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), movieTexture);
#endif
}
}
Anyone knows what's wrong here ? Thanks in advance for your answers.
Your answer
Follow this Question
Related Questions
Problem playing audio for streaming video 0 Answers
Black MovieTexture with Audio streaming on Mac? -1 Answers
WWW in Editor getting request with null attributes 1 Answer
Splash videos on android and iOS? 0 Answers
Unity for showing a html stream 0 Answers