play head wait!!!

When I had just begun using Director I thought the only way to get a vid to play full length was to stretch its frames 'til the end in the Score layer. This was very tedious and I wondered to myself how much do I have to stretch the movie frames 'til I reach the end. Surely, I knew there was another way. Thankfully, there is and I've brought this simple tutorial to you to avoid silly notions, like my initial one. ;) This tutorials presents you code which allows the play head to wait until the entire digital video has played. After which, the play head will jump to the next frame of marker specified.

Open your Director movie add the following code/script to your quicktime movie.

Snippet 1

  1. property thisSprite

  2. property thisMember

  3. property thisDuration

  4. on beginsprite me

  5. --define what you're dealing with (channel)

  6. thisSprite = me.spriteNum

  7. thisMember = sprite(thisSprite).member.name

  8. thisDuration = member(thisMember).duration

  9. end

  10. on exitFrame me

  11. if sprite(thisSprite).movieTime >=thisDuration then

  12. --video is done playing; now go to place specified in brackets _movie.go("gohere")

  13. end if

  14. end

You can see that the code above has three properties.

thisSprite is a representation of the channel in which the sprite (vid) was placed. thisSprite can be seen as a variable which holds the channel number of the sprite in its memory cell. It's not 'needed', you could have had these lines instead:

Snippet 2

  1. thisMember = sprite(me.spriteNum).member.name

  2. if sprite(me.spriteNum).movieTime>= thisDuration then

As you can see, me.spriteNum replaces where thisSprite once was. thisSprite is a property or variable that holds the value of me.spriteNum.


thisMember represents a cast member within the cast member library

This line : sprite(me.spriteNum).member.name represents the member name as well as its properties (file type). It could have been replaced with the following:

member("quicktimevid")

Snippet 3

  1. thisMember = member("quicktimevid")

The difference between lines 1 in snippet 2 and 3, is that snippet 2 makes use of the dot operator and one needs not know the name/label of the file or member.

thisDuration represents the duration or play time of the digital video.

In snippet 2, code line labeled 2 is where the main decision is made based on certain conditions. All line 2 states is: if quicktime video play time is equal to its total duration then ...
In this case, once the statement is true, the next statement is executed.

Alrighty, the code has been briefly explained. I now request that you download this document. Check out the structure and observe what the code does. Please note the defined behavior movie controller in the Behavior Channel. It is very important. Without it, the play head would skip to the next frame without playing the full movie and the code we spoke of above would never 'work'. Try removing it to see what happens. Goes right through, huh? The markers label where the play head should jump to after the digital movie has been played in its entirety. Notice, that I defined two markers. You can actually see the 'jump' by my doing so as after the movie is played the play head skips all the frames between movie controller behavior and t marker. The obedient play head didn't even stop to show off what's happening with marker d. If you wanted the play head to move to another marker, say d marker, simply change this line:

_movie.go("t")

Replace t with d. That's all it takes. Simple huh?

Happy camping!!