public sealed class VideoPlayerPlays a video: decodes ahead of the clock, and says which frame is current.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Three moving parts and one rule. A decoder produces frames, a queue holds the next few, and a clock says what time it is; the rule is that the current frame is the newest one whose timestamp has passed. Everything else here — the thread, the pool, the loop offset, the counters — exists to make that rule survive a decoder that is occasionally slow.
Late frames are dropped, never shown late. If the clock has passed three frames since the last update — a stall, a breakpoint, a game running at 20 fps against 60 fps content — the player shows the third and counts two in FramesDropped. Showing them in sequence would put the picture behind the sound and keep it there, which is the failure mode that never recovers on its own.
The decode thread is optional and the pump is public. Exactly as AudioStreamPump is: Service does the whole job synchronously, so a single-threaded platform calls it from its own loop and a test drives it frame by frame with no timing at all.
CurrentFrame belongs to the player. It is valid until the next Update, which is when the frame goes back to the pool. Anything that needs to keep it copies it — see VideoFrame.CopyFrom — and anything that uploads it to a texture does so in the same frame, which is what VideoTexture is for.
Fields and properties (14)
public VideoPlayerOptions OptionsWhat it was set up with.
public IVideoStreamDecoder DecoderThe decoder behind it.
public VideoClock ClockThe clock deciding which frame is current.
public VideoPlaybackState StateWhat the player is doing.
public bool LoopWhether it starts again when it ends.
public VideoFrame? CurrentFrameThe frame that should be on screen, or before the first one.
public uint FrameVersionBumped every time CurrentFrame becomes a different picture.
public long FramesShownHow many frames have been shown.
public long FramesDroppedHow many were decoded, became due, and were skipped because a newer one was also due.
public long DecodeStallsHow many updates found the queue empty with the video still playing.
public int QueuedFramesHow many decoded frames are waiting.
public TimeSpan PositionWhere playback has got to.
public TimeSpan DurationHow long the video is, or zero if the container did not say.
public Int2 DisplaySizeHow big the picture is meant to look, which anamorphic content answers differently.
Methods (10)
public VideoPlayer(IVideoStreamDecoder decoder)Creates a player over a decoder, set up the way a cutscene wants.
public VideoPlayer(IVideoStreamDecoder decoder, VideoPlayerOptions options)Creates a player over a decoder.
public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Play()Starts or resumes playback.
public void Pause()Holds the current frame.
public void Stop()Stops and returns to the start.
public void Seek(TimeSpan position)Moves to a position.
public void FollowAudio(IAudioSampleProvider audio, TimeSpan offset = default(TimeSpan))Makes the sound the master clock, and the picture follow it.
public void Update(TimeSpan delta)Advances the clock and chooses the frame to show.
public bool Service()Decodes at most one frame into the queue.
Used by (13)
- VideoGameVideoPlayback
- AudioMasterClockTestsVixen.Video.Tests
- VideoFitVixen.Video
- VideoPlaybackVixen.Video
- VideoPlaybackTestsVixen.Video.Tests
- VideoPlayerTestsVixen.Video.Tests
- VideoRenderTargetVixen.Video.Rendering
- VideoSurfaceVixen.Video
- VideoSurfaceUploaderVixen.Video.Rendering
- VideoSystemVixen.Video
- VideoSystemTestsVixen.Video.Tests
- VideoTextureVixen.Video
- VideoTextureTestsVixen.Video.Tests