How to make this script load next level after audio stops playing

Hi Guys. I found out this plays my video.

var movTexture : MovieTexture;

function Start () {
    renderer.material.mainTexture = movTexture;
    movTexture.Play();
}

How would i make this load the next scene after the video or audio has stoped playing. I have seen some other questions of the same idea but i can not get a definitive answer. Would love all the information you can share. thank you.

Like this:

function Start () {
    renderer.material.mainTexture = movTexture;
    movTexture.Play();
    do
    {
         yield null;
    } while (movTexture.isPlaying);
    Application.LoadLevel(whatever);
}

personally I would do a simple:


if ( movTexture.isPlaying == false ) {
   Application.LoadLevel( "MyLevel" );
}

There are several reasons this can be beneficial to other method one is simply the whole game can continue execution without being stuck in a do…while loop so for instance you could have a loverly background effect running through and once the sound stops it then moves on and loads the level.

I would somehow measure how long the movTexture playtime is and make a counter which loads the scene after the time is lapsed.