Saving a QuickTime movie
You can make the subsequent displays of a graphic window into frames of a movie, a QuickTime video. You can choose the duration of each frame in the movie.
Proceed in three steps.
- 1. provide the graphic window with a reference to a new file as its movie file property.
-
set the_root_path to (path to desktop as text)
set the_movie_path to the_root_path & (make new name) -- provides a unique file name
set movie file of window "untitled" to file the_movie_path
If you do not provide a movie file property before, you can provide it when the script attempts to save the movie (step 3).
- 2. to save the current display of the graphic window into a new frame of the movie, call add movieframe. You can specify the duration, in seconds.
-
add movieframe w duration 1/30 -- 1/30 second
- 3. when you are done with all the frames save the movie by applying the save command to the movie file property of the graphic window.
-
set f to save movie file of w
or: save movie file of w in file "..."
Instead of saving the whole graphic window's graphics into a movie you can save only some specific graph, namely a graphic view. You do so by passing to add movieframe a reference to a graphic view instead of a reference to the graphic window. However, the movie file remains a property of the graphic window.
set v to graphic view 1 of w
add movieframe v duration 1/30
Playing and controlling a QuickTime movie
Smile can open and play movies. To open the movie in Smile drop its icon onto Smile's icon, or use the following syntax:
set mw to DoOpen(theMovieFile)
play mw
-- pause the movie:
stop mw
You can also use the standard controls to play the movie, pause it, or view it frame by frame.
To view a movie frame by frame by script, use the «class STEP» property: a value of 1 shows the next frame, a value of -1 shows the previous frame, and so on. Force the movie window to refresh its display with the draw command.
set «class STEP» of mw to 1
draw mw
A QuickTime movie opens in Smile as a movie window. You can use the following properties of movie windows.
- duration: returns the movie's total duration.
-
duration of mw
-- 5.936666666667
- elapsed time: returns or sets the movie's current position, in seconds.
-
elapsed time of mw
-- 4.083333333333
set elapsed time of mw to 3.0
- count frames: returns the movie's total number of frames.
-
count frames of mw
-- 361
- frame index: returns or sets the movie's current frame index.
-
frame index of mw
-- 1
set frame index of mw to 42
According to the corresponding setting in the Preferences dialog Smile will play the movie in black & white or in color. In black & white mode you can import data from images as described in the Chapter Data import/export.
|