www.movie not playing?

I want to play a www movie on a 3dobject (a tv) once downloaded. The problem I’m having is that all I see on the object is the first frame of the movie. Nothing plays. Any ideas? This code is basically a cut and paste of this but replacing the guiTexture with a mesh (a plane).

var url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
var myScreen :GameObject;

function Awake()
{
	myScreen=gameObject;
	DontDestroyOnLoad(this);//temp
}

function Start () {
	// Start download
	var www = new WWW(url);

// Make sure the movie is ready to start before we start playing
var movieTexture :MovieTexture = www.movie;


myScreen.renderer.material.mainTexture= movieTexture;

while (!movieTexture.isReadyToPlay)
{
	yield;
}
print("movie is ready to play!!");

// Assign clip to audio source
// Sync playback with audio
audio.clip = movieTexture.audioClip;

// Play both movie & sound
movieTexture.Play();
audio.Play();

}

1 Answer

1

I discovered the problem. A movie texture seems to automatically Stop playing whenever a new scene/level is loaded. To fix this I simply changed the Start() function to function OnLevelWasLoaded (). The movie plays fine.