- Home /
Problem playing movietexture only with local file
Hi!
It's my first time on this forum so please excuse any mistake I could do regarding forum rules.
I have Unity Pro and am trying to play a movie from the Streaming Assets folder (standalone build). I can successfully play the movie with the WWW class, as long as it uses an url from the web. The movie is in ogg format. That same movie, when inside the Streaming Assets folder, fails to play. Trying a few things I found out it's actually never ready to play.
Here's the code:
IEnumerator StartVideo ()
{
WWW www = new WWW(System.IO.Path.Combine(Application.streamingAssetsPath, "sample.ogg"));
while (!www.isDone)
yield return null;
MovieTexture movieTexture = www.movie;
GetComponent<RawImage>().texture = movieTexture;
MovieTexture movieToPlay = GetComponent<RawImage>().texture as MovieTexture;
movieToPlay.Play();
}
Any idea why it works on the web and not in the Streaming Assets folder? I can see that it was imported successfully in Unity, so that's not the issue.
Thank you very much!
Answer by saschandroid · Nov 24, 2015 at 08:12 AM
WWW www = new WWW("file:///" + System.IO.Path.Combine(Application.streamingAssetsPath, "sample.ogg"));
Thank you for your answer @saschandroid. Unfortunately, that didn't do the trick (I had already tried something similar with only two forward slashes ins$$anonymous$$d of three, and it didn't work also).
There might be something wrong with our Unity, or with this version in particular (version 5.2.2f1)...
This works for me:
$$anonymous$$ovieTexture movieTexture;
IEnumerator StartVideo()
{
WWW www = new WWW("file:///" + System.IO.Path.Combine(Application.strea$$anonymous$$gAssetsPath, "movie.ogg"));
Debug.Log("www: " + www.url);
yield return www;
movieTexture = www.movie;
Debug.Log("$$anonymous$$ovie is ready to play: " + movieTexture.isReadyToPlay);
}
$$anonymous$$mh, this works for me (movie is ready to play):
$$anonymous$$ovieTexture movieTexture;
IEnumerator StartVideo()
{
WWW www = new WWW("file:///" + System.IO.Path.Combine(Application.strea$$anonymous$$gAssetsPath, "movie.ogg"));
yield return www;
movieTexture = www.movie;
Debug.Log("$$anonymous$$ovie: " + movieTexture.isReadyToPlay);
}