| |
MoviePlayerMorph
category: Morphic-Demo
superclass: BookMorph
subclasses:
MoviePlayerMorph plays images from a file using async io. The file format is simple but non-standard (see below).
The heart of the play logic is in the step method. Note that play is driven by a simulated time since start. For a movie with a sound score, this is the millisecondsSinceStart of the score player, whereas a movie by itself gets this from the millisecondClock minus msAtStart.
Movie players are designed to be used in three ways
1. Select a movie in the file list, 'open as movie', and play it.
2. As in (1), but drop thumbnails for various frames into a
MIDI piano roll to synchronize video with music.
3. Open a MoviePlayerMorph as a 'new morph', and choose
'make a new movie' from the menu.
In (1) and (2), a shift-drag is used to 'tear off' a thumbnail reference morph to the currently visible frame of this clips. The thumbnail can then be dropped in a MIDI score player to either syncronize that frame with what point in the music, or to cause that clip to being playing in the shared player of a SqueakMovie plex.
When making a new movie, an empty score and piano roll are linked to the movie player, as a SqueakMovie plex. You can then open another movie as a clip, and drop a thumbnail morph into the score to start that clip playing at that frame in the shared player. If you pause while playing that clip, you can manually play the clip forward and backward in the current clip. if you stop at a given frame, you can choose 'end clip here' from the shared player menu to shorten or lengthen the clip.
Clips can be moved by picking up the starting thumbnail (use halo black handle), and dropping them elsewhere. If you try to place one clip in the middle of another, it will slide to the end. If you position one clip close to the end of another, it will sidle up to make them contiguous.
If you wish a soundtrack to be included with a clip, make sure it has been opened in the source clip player before tearing off the starting thumbnail.
About the .movie file format...
The following code was used to convert 27 files into a movie. They were named
'BalloonDrop10fps003.bmp' through 'BalloonDrop10fps081.bmp'
incrementing by 003. Each was known to be a 320x240 image in 32-bit BMP format.
Note the 27 in the 5th line is the number of frames, = (3 to: 81 by: 3) size.
| ps zps f32 out ff |
out _ FileStream newFileNamed: 'BalloonDrop10fps.movie'.
out binary.
ff _ Form extent: 320@240 depth: 16.
#(22 320 240 16 27 100000) , (7 to: 32)
do: [:i | out nextInt32Put: i].
3 to: 81 by: 3 do:
[:i | ps _ i printString. zps _ ps padded: #left to: 3 with: $0.
f32 _ Form fromFileNamed:
'BalloonDrop10fps' , zps , '.bmp'.
f32 displayOn: ff at: 0@0. "Convert down to 16 bits"
ff display; writeOnMovie: out].
out close.




|
|