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

Get MovieTexture Time

Discussion in 'Scripting' started by radiolobito, Feb 1, 2010.

  1. radiolobito

    radiolobito

    Joined:
    Jun 12, 2009
    Posts:
    117
    i'm using this code:
    Code (csharp):
    1.  
    2. var mostrador : MovieTexture;
    3.  
    4. function OnGUI (){
    5. GUI.DrawTexture (Rect 0,0,720,480), mostrador);
    6. audio.clip = mostrador.audioClip;
    7. print (audio.clip.length);
    8. mostrador.Play();
    9. audio.Play();
    10. }
    11.  
    But i cannot detect the length of the "mostrador" MovieTexture or the length of the audio clip related to "mostrador". How can i do that? it reports always "0" in the console.

    and there's a way to "jump" into a specific point of the movieTexture and Audioclip?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    No, there is no way to jump to specific positions in the movie.
    You can only start, pause and stop it.

    As such the informations on the position within the movie wouldn't be of use.

    As for the length: you can check if the movie is still playing instead to detect the end
     
  3. radiolobito

    radiolobito

    Joined:
    Jun 12, 2009
    Posts:
    117
    thanks a lot
     
  4. cowlinator

    cowlinator

    Joined:
    Mar 15, 2012
    Posts:
    69
    Actually, it would be a lot of use. Having no access to the position means that there is no good way to make any kind of OnMovieEnd event that actually works if you pause the video:

    Code (CSharp):
    1. void Play()
    2. {
    3.     movieTexture.Play();
    4.     StartCoroutine(Wait(movieTexture));
    5. }
    6.  
    7. void Pause()
    8. {
    9.     movieTexture.Pause();
    10.     StopAllCoroutines();
    11. }
    12.  
    13. IEnumerator Wait(MovieTexture m)
    14. {
    15.     yield return new WaitForSeconds(m.timeRemaining);
    16.     OnMovieEndHandler();
    17. }
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Problem is if the movie exposes a 'Position', then the common requirement is that it can be read and written and the ogg theora present in Unity does not allow for seeking. Thats likely why it does not expose the current position as a read value.

    I otherwise agree with you that it would be usefull though your scenario can easily be solved by storing the start time + duration and then calculate the remaining time upon the pause(s).