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

movie texture never ready to play

Discussion in 'Scripting' started by VirtualDestructor, Oct 15, 2014.

  1. VirtualDestructor

    VirtualDestructor

    Joined:
    May 3, 2014
    Posts:
    40
    I am trying to load a movie file using a WWW object and then make it a texture of a material and then play it back. The WWW object seems to load the movie texture without error, but when I check isReadyToPlay for the movie texture it is always false. I am certain that the URL is correct (it is a local file URL and I have confirmed that it is correct). Has anyone else seen this before? Does anyone know a workaround? I need to load the file from a URL. I've tried several movie files in different formats (that work as regular movie textures when not being loaded using a WWW object). Here is the code:

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class AssetBundleMovieTest : MonoBehaviour {
    6.     private string url = "file:///C:/Users/monkey/Downloads/Delta.mpg";
    7.     private MovieTexture movieTexture;
    8.  
    9.     void Start() {
    10.         StartCoroutine(LoadMovie());
    11.     }
    12.  
    13.     void Update() {
    14.         if (movieTexture != null && movieTexture.isReadyToPlay) {
    15.             // this never gets called
    16.             Debug.Log("The movie is ready to play");
    17.         }  
    18.     }
    19.  
    20.     private IEnumerator LoadMovie() {
    21.         WWW www = new WWW(url);
    22.         yield return www;
    23.         movieTexture = www.movie;
    24.         if (movieTexture != null) {
    25.             // this gets called
    26.             Debug.Log("Loaded the movie texture");
    27.         }
    28.     }
    29. }
    30.  
     
    Last edited: Oct 15, 2014
  2. DigitalSalmon

    DigitalSalmon

    Joined:
    Jul 29, 2013
    Posts:
    99
    http://docs.unity3d.com/ScriptReference/WWW-movie.html

    According to the documentation, www.movie must be in ogg format. There are lots of online/free converters for ogg files.

    Unity plays movies from other formats when they are not loaded via www because it has an internal method for converting to ogg - When it's playing, its actually reading its ogg file.

    I'd highly recommend AVPro Windows Media if you are working on windows only - It's very performant, and relatively simple to use. Failing that, AVPro Quicktime is a good multi-platform option. Both have free demos online.
     
  3. VirtualDestructor

    VirtualDestructor

    Joined:
    May 3, 2014
    Posts:
    40
    Thanks DigitalSalmon, you are correct the format was wrong. It had to be ogv. I overlooked that in the documentation.
     
  4. abzork

    abzork

    Joined:
    Oct 1, 2014
    Posts:
    7
    I am using ogv format already , But still its not loading ever,
    I am converting files to ogv using this website : http://www.online-convert.com/
    not sure what's going wrong , i am using Unity Plus edition 5.6 on macOsX .
    Please help,
    Regards,
     
  5. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    MovieTexture is obsolete (and was always terrible TBH). Unity 5.6 has a new VideoPlayer class which is much better and much easier to use; use that instead.
     
  6. omarojo

    omarojo

    Joined:
    Feb 12, 2015
    Posts:
    4
  7. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970