Moving Frame by Frame
One
popular feature for playback is the
ability to step forward exactly one frame. It turns out to be
trickier than one might initially expect: it’s not
like there’s a Movie.nextFrame( )
method. Indeed, a Movie might not have a video
track at all, if it represents an MP3 or some other audio-only media.
So, finding the next frame requires being a little smarter about
looking inside the Movie’s
structure.
How do I do that?
This example builds on the earlier BasicQTButtons
code. In this example, the implementations of the forward and back
buttons are altered so that instead of changing the play rate, they
change the current time to be the next frame before or after the
current time. For space, this example shows only the changes from the
original BasicQTButtons.
This example needs to import quicktime.std to use
StdQTConstants
, and
quicktime.std.clocks for some time-related
classes. It also adds an instance variable
visualTrack, which is found with the following
call:
theMovie = m;
// find video track
visualTrack =
m.getIndTrackType (1,
StdQTConstants.visualMediaCharacteristic,
StdQTConstants.movieTrackCharacteristic);If a visual track isn’t found, the
revButton and fwdButton are
disabled later in the constructor.
Finally, a new implementation of actionPerformed() does the frame-step logic when the
revButton or fwdButton is
clicked:
if (e.getSource( ) = = revButton) { TimeInfo ti = visualTrack.getNextInterestingTime ( StdQTConstants.nextTimeMediaSample, theMovie.getTime( ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access