-
-
Save col000r/d6361ba2147b2ea454ee to your computer and use it in GitHub Desktop.
Unity Video Streaming Example, slightly rewritten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
[RequireComponent (typeof(AudioSource))] | |
public class Test1 : MonoBehaviour { | |
public string url = "http://www.unity3d.com/webplayers/Movie/sample.ogg"; | |
IEnumerator Start () { | |
// Start download | |
WWW www = new WWW(url); | |
// Make sure the movie is ready to start before we start playing | |
MovieTexture movieTexture = www.movie; | |
while ( !movieTexture.isReadyToPlay && string.IsNullOrEmpty(www.error) ) { | |
Debug.Log ( "Waiting... " + www.progress ); | |
yield return null; | |
} | |
Debug.Log ("Done waiting! e: " + www.error + ", done? " + www.isDone); | |
// Assign clip to audio source | |
// Sync playback with audio | |
audio.clip = movieTexture.audioClip; | |
renderer.material.mainTexture = movieTexture; | |
// Play both movie & sound | |
movieTexture.Play(); | |
audio.Play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment