Search Unity

FullScreenMovieControlMode? Confused

Discussion in 'Scripting' started by kilt, May 31, 2012.

  1. kilt

    kilt

    Joined:
    Oct 12, 2011
    Posts:
    136
  2. kilt

    kilt

    Joined:
    Oct 12, 2011
    Posts:
    136
    Umm, I got the video to FastForward after learning that the audio syncs with the movie, bit it does not rewind?

    Here is the code in full

    Code (csharp):
    1. var url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
    2.  
    3. var movieTexture : MovieTexture;
    4.  
    5. function Start ()
    6. {
    7.     // Start download
    8.     var www = new WWW(url);
    9.  
    10.     //yield www;
    11.     // Make sure the movie is ready to start before we start playing
    12.     movieTexture = www.movie;
    13.     while (!movieTexture.isReadyToPlay)
    14.         yield;
    15.  
    16.  
    17.     // Initialize gui texture to be 1:1 resolution centered on screen
    18.     guiTexture.texture = movieTexture;
    19.  
    20.     transform.localScale = Vector3 (0,0,0);
    21.     transform.position = Vector3 (0.5,0.5,0);
    22.     guiTexture.pixelInset.xMin = -movieTexture.width / 2;
    23.     guiTexture.pixelInset.xMax = movieTexture.width / 2;
    24.     guiTexture.pixelInset.yMin = -movieTexture.height / 2;
    25.     guiTexture.pixelInset.yMax = movieTexture.height / 2;
    26.  
    27.     // Assign clip to audio source
    28.     // Sync playback with audio
    29.     audio.clip = movieTexture.audioClip;
    30.  
    31.     // Play both movie  sound
    32.     movieTexture.Play();
    33.     audio.Play();
    34. }
    35.  
    36. function OnGUI()
    37. {
    38.             if (GUI.Button(Rect(0, 0, 60, 30), "Pause"))
    39.             {
    40.                 movieTexture.Pause();
    41.             }
    42.            
    43.             if (GUI.Button(Rect(0, 30, 60, 30), "Stop"))
    44.             {
    45.                 movieTexture.Stop();
    46.             }
    47.            
    48.             if (GUI.RepeatButton(Rect(0, 60, 60, 30), "FastForward"))
    49.             {
    50.                 audio.time += 0.2f;
    51.             }
    52.            
    53.             if (GUI.RepeatButton(Rect(0, 90, 60, 30), "Rewind"))
    54.             {
    55.                 audio.time -= 0.2f;
    56.             }
    57.            
    58.             if (GUI.Button(Rect(0, 120, 60, 30), "Play"))
    59.             {
    60.                 movieTexture.Play();
    61.             }
    62.            
    63.             //audio.time = GUI.HorizontalSlider(Rect(150, 80, 425, 15), audio.time/audio.clip.length * audio.clip.length, 0.0f, audio.clip.length);
    64. }
    65. // Make sure we have gui texture and audio source
    66. @script RequireComponent (GUITexture)
    67. @script RequireComponent (AudioSource)
    Another question, when I try to add the sync bar, the movie decides to not go the speed it is designed to go.

    edit: Did I really just type unsigned int :p
     
    Last edited: Jun 1, 2012
  3. light766

    light766

    Joined:
    Apr 23, 2009
    Posts:
    250
    Hmm, I was playing around with your script and it seems like it is a unsigned variable. I have no idea.