Each player's internal clock determines how fast and in what direction it plays. Ordinarily this clock is synchronized to a default clock, such as the real-time clock. Using the synchronization support provided by TPlayer, you can synchronize a media player to any clock. When a player is synchronized to a clock, its timing is dependent on that clock.
You can synchronize a media player to an external clock using the TPlayer::SyncTo function. For example, to synchronize a graphic player to an audio player, you would:
// Synchronizing two players TSyncableClockSurrogate audioClock; anAudioPlayer.GetClock(audioClock); aGraphicPlayer.SyncTo(audioClock);
The current position of a player is controlled by it's clock time; however, the current position is always bound between zero and the duration of the loaded sequence. The internal player clock must read between zero and the duration for the player to play.
If a player is synchronized to an external clock, the player's current position is determined by the synchronization relationship. When you call SetRate, you can change a player's clock time using an offset from the external clock's clock time. By default, the offset is zero, which sets the clock time of the player to the time of the external clock. Alternatively, you can use SyncToKeepMyTime, which does not reset the player's time.
To play an audio or video sequence backward, you reverse the flow of time. If you're using delays, it's important to take into account the direction of the time flow when you compare times. The results of the comparison depend on the direction that time is flowing. If time is flowing toward the compared time, the compared time is directionally greater, or in the future. If time is flowing away from the compared time, the compared time is directionally less, or in the past. Delays unblock if at any time the delay time is directionally less than the compared time.
For more information about clocks and timing, see Chapter 11