Hi, I want to load local movie texture in unity pro, but the movie can’t be played and there is no error report too. Please tell me why, thanks.
Here is my code.
using UnityEngine;
using System.Collections;
public class SectorMovie : MonoBehaviour {
public string oggUrl="file://E:/OldFiles/Unity/20AVI/Test/mlin.ogg";
MovieTexture movTexture;
private WWW urlVid;
IEnumerator Start() {
urlVid = new WWW(oggUrl);
yield return urlVid;
}
void Update()
{
if(urlVid.isDone)
{
movTexture = urlVid.movie;
renderer.material.mainTexture = movTexture;
if (movTexture.isPlaying)
{
movTexture.Pause();
}
else
{
movTexture.Play();
if(movTexture.isPlaying)
}
}
}
}
your update statement boils down to:
if download is done
grab movie from download
set movie onto renderer
if movie is playing
pause
else
play
some random if statement
so frame “one” after the download is done it’ll play, frame “two” it’ll pause… i’m guessing (since the docs don’t say anything on this bit) that “isPlaying” is still true whilst paused so it’ll just set the movie to pause each frame thereafter…
at least that’s how it looks to me, can you put some debug lines in there and see where it’s failing?
Hi, LeftyRighty, Thanks for your help. I added “print(urlVid.error);” in my code, and it shows “ malformed”. So , I think I didn’t use url correctly.
Anyway, problem not solved yet.
using UnityEngine;
using System.Collections;
public class SectorMovie : MonoBehaviour {
public string oggUrl="file://E:/OldFiles/Unity/20AVI/Test/mlin.ogg";
MovieTexture movTexture;
private WWW urlVid;
//
IEnumerator Start() {
urlVid = new WWW(oggUrl);
yield return urlVid;
print(urlVid.error);
}
//update
void Update()
{
if(urlVid.isDone)
{
movTexture = urlVid.movie;
renderer.material.mainTexture = movTexture;
if (movTexture.isPlaying)
{
}
else
{
movTexture.Play();
if(movTexture.isPlaying)
print("playing");
}
}
}
}