assigning MovieTexture

I’m trying to dynamically load a video from StreamingAssets folder, but somehow the www.movie returns a movie texture with duration -1

    public    MovieTexture     movTex;
    void Start ()
    {
#if UNITY_EDITOR
        LoadIntroMovie();
#else
       // Play intro movie on Handheld device
#endif
    }

void LoadIntroMovie()
    {
        movTex = null;

        string videoFilePath = Application.streamingAssetsPath+"/Intro Videos/sample_mpeg4.mp4";
        if (! System.IO.File.Exists(videoFilePath) )
        {
              Debug.LogError(videoFilePath + " does not exist!");
              return;
        }
     
        WWW www = new WWW( "file://" + videoFilePath );
     
        if (www != null)
        {
            while ( !www.isDone ) Debug.Log("Loading data " + www.url + "...");
            Debug.Log(www.url + " loaded!");
            movTex = www.movie;
        }

        print("Movie texture duration : " + movTex.duration); // ERROR : Movie texture duration : -1

Any idea what went wrong?

  • The video file is definitely not corrupted. It’s the sample .mp4 file I downloaded from Quick Time website and it plays OK if I simply drag and drop the file into the quad I use as a movie plane
  • The www loading method definitely work if I am about to fetch a text file (instead of movie)

bump.

Could anyone help me?