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 5 how to load movie from url

Discussion in 'Scripting' started by Smagacz, Aug 10, 2016.

  1. Smagacz

    Smagacz

    Joined:
    Feb 10, 2016
    Posts:
    23
    Hi, I'm trying to load a movie from url but it doesn't work, here is my code:

    Code (CSharp):
    1.        
    2.  
    3.  public MovieTexture movieTexture;
    4.  public AudioSource audioSource;
    5.  
    6.     void Start()
    7.     {
    8.         StartCoroutine(StartVideo());
    9.     }
    10.     IEnumerator StartVideo()
    11.     {
    12.         var wwwData = new WWW("http://techslides.com/demos/sample-videos/small.ogv");
    13.         yield return wwwData;
    14.         MovieTexture m = wwwData.movie;
    15.         while (!m.isReadyToPlay)
    16.         {
    17.             print("WaitAndPrint " + Time.time);
    18.         }
    19.     }
    MoviePlayback::LoadMovieData got NULL!
    UnityEngine.WWW:get_movie()
    <StartVideo>c__IteratorA:MoveNext() (at Assets/Scripts/MovieTexturePlayer.cs:29)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

    Unity ver. 5.4 0f3
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    which is line 29 in your script?
     
  3. Smagacz

    Smagacz

    Joined:
    Feb 10, 2016
    Posts:
    23
    Line 29 is: MovieTexture m = wwwData.movie; It' s works then i drag and drop local movie to script field without www().
    I was tring to change movie format but it didint worked. Now i'm loading my local movies from resources. by:
    Code (CSharp):
    1.  string movieTexturePath = "Unity";
    2.         movieTexture = (MovieTexture)Resources.Load(movieTexturePath, typeof(MovieTexture));
    3.         GetComponent<RawImage>().texture = movieTexture;
    4.         audiosource.clip = movieTexture.audioClip;
    5.         movieTexture.Play();
     
  4. nicolelu

    nicolelu

    Joined:
    Nov 4, 2016
    Posts:
    1
    I have the same problem when using the WWW to load movies, and I use your method,but seems it couldn't find the movie,what kinds of format did it support? I've try .ogv format
     
  5. TheModdersDen

    TheModdersDen

    Joined:
    Jul 23, 2014
    Posts:
    6
    Same here! Any fix for this yet? Sorry if I'm not supposed to reply to this thread, but this seems to be a really irritating problem in the community...

    EDIT:
    Finally found out what was wrong... It appears that the built-in WWW.Movie code doesn't support MP4 videos (or anything other than ogg/ogm videos)... Guess I've got to find a way to convert them on the fly... Dang...
     
    Last edited: Dec 7, 2016
  6. psicodead

    psicodead

    Joined:
    Mar 9, 2017
    Posts:
    1
    The videos should be .ovg, if it doesn't work try using unity 5.2.3, It seems to be a bug on unity 5.x with www.movie (the bug isn't on 5.2.3)

    PD: some people says that it is working even when displaying the error, but just if using .ovg videos