IEnumerator LoadExternalCoroutine(string name, UIVideo video)
{
//load only once
string url = "file://" + GameManager.Instance.mainGame.ExternalResourcePath + "/" + name + ".ogv";
// Debug.Log(">>>>>>> Load file:" + url);
//WebPlayerDebugManager.addOutput("_______ LoadExternalCoroutine url: "+url, 1);
//release resources for www
DestroyImmediate(video.video.movieTexture);
video.video.movieTexture = null;
WWW www = new WWW(url);
// while (!www.movie.isReadyToPlay);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
video.video.movieTexture = www.movie;
video.Play(); //hack: get the first frame
video.Stop();
}
else
{
Debug.LogWarning(www.error);
MovieTexture t = Resources.Load<MovieTexture>(name);
if (t != null)
{
video.video.movieTexture = t;
}
}
www.Dispose();
www = null;
}