Tutorial 11 - Digital Video
This tutorial introduces you to using digital video
in you movie. You will learn how to import, insert,
get information from and sequence other media elements
to digital video.
1. Open a new movie, set the stage size to 340x380,
set the stage colour to white and save this movie
as DVtutorial.dir.
2. Next, import the digital video Clapper.avi into
the cast.
Download
Clapper.avi here
3. Now click and drag the cast member Clapper and
place it in the score starting at channel 1 frame
1. Position the sprite in the top portion of the
stage.
4. Extend the length of the sprite to 10 frames.
Figure 11.1: Extend the Clapper
sprite over 10 frames
5. Ensure that the "Loop Playback" option
is disabled: select Control and remove the tick
from the left side of the Loop Playback menu item.
Figure 11.2: Deselecting the Loop
Playback Option
6. Now play the movie, you will see that the Director
movie ends before the digital movie ends, this is
because the playback head reached frame 10 before
the digital video has a chance to run it's course
but this is OK since we are going to use two different
methods of sequencing with digital video: Cue Points
and the movieTime.
Cue Points
A Cue point is marker that can be embedded in
digital video or sound file. Director is capable
or recognising these markers and a message is
send at a specific time in the play cycle. Let's
use the end cue point in the Clapper digital
video to prevent the play-head from ending the
movie until the entire video has played.
7. In frame 10 (the last frame in the movie), double
click in the tempo channel to open the tempo property
box.
Figure 11.3: Wait for Cue Point
8. Select the "Wait for Cue Point" radio
button.
9. From the channel drop-down option list select
"1:Clapper".
10 From the Cue Point drop-down option list select
"{End}".
This will instruct director to remain at frame
10 until the END cue point has been reached, or
until the video has finished playing.
11. Play your movie. You will now be able to view
the entire video!
The movieTime
The movieTime is a lingo property that allows
us to set ant test the position of the play-head
inside a digital video.
MovieTime is counted in ticks (1/60th of a second)
so for example if a digital video plays at 15fps
for 60 seconds (i.e. 1500 frames) the movie will
end at tick 3600 and will run at 4 ticks per frame.
We are going to use the movieTime property to
find out exactly when certain events occur within
the video and based on the information we will
sequence some sound and text with the video.
12. Extend the length of sprite 12 to frame 40
and remove the tempo setting by selecting it and
pressing the delete key
13. Create a button and call it "MovieTime".
Position the button in the bottom left corner of
the stage. We will use this button to get the movieTime
for the events we want.
14. Open the Message window (Ctrl. M or Window
> Message). The message window is very useful
for testing code, setting properties and getting
information from director.
15. Click on the button in the cast and open the
cast member script window.
We are going to write some code that will print
the movieTime in the message window, to do this
we will use the "PUT" command.
16. Type the following code:
on mouseUp
put the movieTime of
sprite 1
end
This code will print the movieTime on the video
in Channel 1 at the precise time the mouseUp event
occurs.
17. Ensuring that the message window is visible,
play the movie and click on the button when the
the clapper is slammed shut, in or around 290 you
should find.
We will use this information to tell Director to
play an explosion sound at the exact moment when
the clapper slams shut.
18. Let's import the sound files we'll need to
complete this tutorial:
Party.aif
Explosion.aif
Clapping.aif
19. Import these files into your cast.
20. Create 3 text cast members: "PARTY",
"EXPLOSION" and "CLAPPING"
21. Let's start the video with the party sound,
double-click in frame 1 of the script channel to
open the frame script editor and type the following
code:
on exitFrame
puppetsound 2, "party"
end
Refer to tutorial 10 for further information on
puppetSound
22. Double-click in frame 15 of the script channel
to open the frame script editor, we are going to
get Director to wait at this frame until the movieTime
is larger than 290. Once this time has been reached
we want Director to stop playing the Party sound
and play the Explosion sound AND move onto the next
frame! So, type the following code:
on exitFrame
if the movieTime of sprite
1 < 290 then
go the frame
else
puppetSound 2, "explosion"
go the frame+1
end if
end
Working from the top down:
- on exitFrame --
this script will run when the play-head attempts
to leave or exit the frame
- if the movieTime of sprite
1 < 290 then-- the is the first line
of a conditional IF statement (if a condition
is true then do an action), here the condition
is if the movieTime is less than 290.
- go the frame--this
is the action, which is go to the beginning of
the same frame, effectively loop in the same frame
- else-- every other
case (i.e. when the movieTime is no longer less
than 290)
- puppetSound 2, "explosion"--
Play the sound file "explosion" in channel
2, since the party sound was also playing in channel
two that will now be stopped to make way for the
explosion sound file.
- Go the frame+1--
go the the NEXT frame
- end if-- every
IF statement MUST end with the words end if
- end-- every handler
must end with the word end
23. Test your movie, the party sound starts when
you start the movie & when the clapper shuts
the explosion sound takes over.
Let's add a clapping sound once the explosion sound
has finished, to achieve this we will use the soundBusy
property to check if a sound is still playing.
24. Double-click in frame 30 of the script channel
to open the frame script editor and type the following
code:
on exitFrame
if soundbusy(2) then
go the frame
else
puppetSound 2, "clapping"
go the frame+1
end if
end
Follow the code line by line, you'll see that it
is checking to see if channel 2 is busy (soundBusy(2)).
Once it is free Direct will play the Clapping sound
file, again in channel 2.
Let's finish the movie off with an alert box to
tell our user that the movie has finished.
25. Double-click in frame 35 of the script channel
to open the frame script editor and type the following
code:
on exitFrame
if soundbusy(2) then
go the frame
else
alert "This Movie
has come to an end!!"
go the frame+1
end if
end
Lot's of familiar code here, we're checking for
a sound in channel 2, once all's quite we will display
an alert box the will say "This Movie has come
to an end!!". Once our user clicks the OK button
on the alert box director will go to the next frame
and finish.
26. Test your movie!
27. Finally, insert the 3 pieces of text in the
relevant frames in the score
In this tutorial you have learned
how to:
- import digital video
- control digital files using Cue points
- get the movieTime of a sprite
- sequence sound and text using the movieTime
and soundBusy properties
- Create a simple alert box
Click here for the
.DIR file for this tutorial
Back to director tutorials