Vixen
02b45cc4
csharp
public sealed class VideoClock

What decides which frame is the current one.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Audio is the master clock when there is audio. This is the one design decision in video playback that everybody eventually arrives at, usually after trying the other two. Driving the video from the frame timer and resampling the audio to match makes every speed correction audible — the ear resolves a few cents of pitch and forty milliseconds of timing, and the eye resolves neither. Driving both from the wall clock means correcting both, which is the worst of it. So the sound plays untouched at its own rate, and the picture is chosen to match where the sound has got to.

With no audio, the clock is the frame delta. Advance is called once a frame with the engine's own GameTime, which means a video in a paused game pauses and a video in a game running at half speed runs at half speed — both of which are what a cutscene should do and neither of which a wall clock would give.

Rate is not a resampler. It scales how fast this clock advances, so a video at half rate shows each frame twice as long. The audio track, if there is one, is unaffected and will drift — which is why anything other than 1 is for a video with no sound, or for a scrub.

Fields and properties (5)

  • public TimeSpan Time

    Where playback has got to.

  • public bool IsRunning

    Whether Advance moves it.

  • public double Rate

    How fast it runs relative to real time. One is normal.

  • public Func<TimeSpan>? Master

    Where the time comes from instead, when something else is keeping it — the audio track.

  • public bool IsSlaved

    Whether an external clock is driving it.

Methods (4)

  • public void Start()

    Starts it.

  • public void Stop()

    Stops it where it is.

  • public void Reset(TimeSpan time)

    Moves it, and stops it.

  • public void Advance(TimeSpan delta)

    Moves the clock on by a frame's worth of time.

Used by (3)

  • AudioMasterClockTestsVixen.Video.Tests
  • VideoPlayerVixen.Video
  • VideoPlayerTestsVixen.Video.Tests