Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity Pro, Movie Texture, Dynamic Load of ogv file

Discussion in 'Editor & General Support' started by rmgalante, Apr 25, 2012.

  1. rmgalante

    rmgalante

    Joined:
    Nov 21, 2009
    Posts:
    59
    I have created a 10 second clip with audio and video. I added a plane to my scene. I added the ogv file to my project. I attach the video and the audio to the plane and see that the mesh renderer has updated appropriately. I start the application in the editor, and the movie plays. So I copy my ogv file to a web site because I want to load it dynamically and replace the MovieTexture's texture with the download file.

    Code (csharp):
    1. private IEnumerator DownloadFile(string downloadUrl)
    2. {
    3.     WWW www = new WWW(downloadUrl);
    4.     while(!www.movie.isReadyToPlay)
    5.         yield return www;
    6.        
    7.     try
    8.     {          
    9.         if (www.error != null)
    10.             Debug.Log("EarthRotator.DownloadFile(): WWW Error - " + www.error);
    11.         else
    12.         {
    13.             _movieTexture = www.movie;
    14.             _movieTexture.Play();
    15.                
    16.             Debug.Log("Movie is playing!");
    17.         }
    18.     }
    19.     catch(Exception ex)
    20.     {
    21.         Debug.Log("EarthRotator.DownloadFile(): Exception - " + ex.Message);
    22.         Exception innerEx = ex.InnerException;
    23.         while (innerEx != null)
    24.         {
    25.             Debug.Log("EarthRotator.DownloadFile(): Inner Exception - " + innerEx.Message);
    26.             innerEx = innerEx.InnerException;
    27.             }
    28.     }
    29. }
    30.  
    The files downloads fine and is ready to play. I get no exceptions. I see the message, "Movie is playing!" But nothing happens. The same file that I'm playing in the project will not play when loaded dynamically to the same MovieTexture.

    Here is a link to the file. I created it with ffmpeg2theora. It plays in VLC.

    http://www.galaware.net/Videos/AsteroidChase.ogv
     
    Last edited: Apr 25, 2012
  2. rmgalante

    rmgalante

    Joined:
    Nov 21, 2009
    Posts:
    59
    I found a way to code it so that it would work.

    Instead of using a 3d plane with a material whose texture is a MovieTexture, I use a GUITexture with a MovieTexture. And that works.

    _guiTexture.texture = www.movie;
    ((MovieTexture)_guiTexture.texture).Play();
     
  3. NeonLost

    NeonLost

    Joined:
    Nov 2, 2012
    Posts:
    1
    Hi, I need your help. I have a script

    Could you show a full example of the corrected code and components Plane?
    How you used the IEnumerator function?
    ty.
     
    Last edited: Nov 2, 2012