VideoStreamPlayback
Contract for a video decoder and audio-frame delivery to a player.
A subclass implements Play/Stop/Paused state, position and duration in seconds, _Update(delta), the current texture and audio properties. Constructing the base resource alone cannot play a file.
_Update receives time advancement already adjusted by the player. MixAudio sends decoded interleaved float samples to the attached sink; it neither captures a microphone nor makes the base class decode video files.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
VideoStreamPlaybackConstructor
public VideoStreamPlayback();Creates a base decoder-state container. Does not decode a file without playback-contract overrides.
Methods15
MixAudio2 overloads
public int MixAudio(int numFrames, ReadOnlySpan<float> buffer, int offset);Sends decoded float samples to the attached player sink. numFrames counts audio frames, buffer interleaves channels, offset indexes float samples. Supply channels × numFrames samples after offset. Returns accepted frames, -1 without a sink/on invalid bounds, or zero for numFrames <= zero. Does not generate sound from an empty array.
| Name | Type | Default |
|---|---|---|
numFrames | int | — |
buffer | ReadOnlySpan<float> | — |
offset | int | — |
numFramesAudio frame count rather than total individual channel samples.
bufferInterleaved float samples sufficient for the requested frames.
offsetStarting float-sample index in buffer.
intSends decoded float samples to the attached player sink. numFrames counts audio frames, buffer interleaves channels, offset indexes float samples. Supply channels × numFrames samples after offset. Returns accepted frames, -1 without a sink/on invalid bounds, or zero for numFrames <= zero. Does not generate sound from an empty array.
public int MixAudio(int numFrames, float[] buffer = null, int offset = 0);Sends decoded float samples to the attached player sink. numFrames counts audio frames, buffer interleaves channels, offset indexes float samples. Supply channels × numFrames samples after offset. Returns accepted frames, -1 without a sink/on invalid bounds, or zero for numFrames <= zero. Does not generate sound from an empty array.
| Name | Type | Default |
|---|---|---|
numFrames | int | — |
buffer | float[] | null |
offset | int | 0 |
numFramesAudio frame count rather than total individual channel samples.
bufferInterleaved float samples sufficient for the requested frames.
offsetStarting float-sample index in buffer.
intSends decoded float samples to the attached player sink. numFrames counts audio frames, buffer interleaves channels, offset indexes float samples. Supply channels × numFrames samples after offset. Returns accepted frames, -1 without a sink/on invalid bounds, or zero for numFrames <= zero. Does not generate sound from an empty array.
_GetChannelsint
public virtual int _GetChannels();Return actual interleaved audio channel count; zero means no audio. Match the MixAudio buffer layout.
intReturn actual interleaved audio channel count; zero means no audio. Match the MixAudio buffer layout.
_GetLengthdouble
public virtual double _GetLength();Return duration in seconds; zero may indicate unknown duration. Not milliseconds or frame count.
doubleReturn duration in seconds; zero may indicate unknown duration. Not milliseconds or frame count.
_GetMixRateint
public virtual int _GetMixRate();Return decoded audio sample rate in Hz, such as 48000. Not the number of samples in the current block.
intReturn decoded audio sample rate in Hz, such as 48000. Not the number of samples in the current block.
_GetPlaybackPositiondouble
public virtual double _GetPlaybackPosition();Return the current position in seconds using a consistent audio/video timeline.
doubleReturn the current position in seconds using a consistent audio/video timeline.
_GetTextureTexture2D
public virtual Texture2D _GetTexture();Return the decoded frame’s current Texture2D. A stable updated resource avoids continually creating textures; null means no texture.
Texture2DReturn the decoded frame’s current Texture2D. A stable updated resource avoids continually creating textures; null means no texture.
_IsPausedbool
public virtual bool _IsPaused();Return your implementation’s stored pause state.
boolReturn your implementation’s stored pause state.
_IsPlayingbool
public virtual bool _IsPlaying();Return actual playback state. Return false after natural completion so VideoStreamPlayer can handle Loop/Finished. Do not conflate pausing with movie completion.
boolReturn actual playback state. Return false after natural completion so VideoStreamPlayer can handle Loop/Finished. Do not conflate pausing with movie completion.
_Playvoid
public virtual void _Play();Implement starting your playback. Define/document repeated-start behavior; the base C# method is empty.
_Seekvoid
public virtual void _Seek(double time);Implement seeking to time in seconds, validating bounds and restoring decoder state. The base method cannot seek.
| Name | Type | Default |
|---|---|---|
time | double | — |
timeTarget position in seconds.
_SetAudioTrackvoid
public virtual void _SetAudioTrack(int idx);Handle the audio-track index according to your format. Neither a bus index nor a channel count.
| Name | Type | Default |
|---|---|---|
idx | int | — |
idxAudio-track index.
_SetPausedvoid
public virtual void _SetPaused(bool paused);Store pause state and suspend decoder advancement without losing required state.
| Name | Type | Default |
|---|---|---|
paused | bool | — |
pausedPause advancement without ending the stream.
_Stopvoid
public virtual void _Stop();Implement stopping and cleaning up the decoder. Your implementation defines position reset, not the empty base C# method.
_Updatevoid
public virtual void _Update(double delta);Advance decoding by delta seconds and update frame/audio data. The player already applies time scaling; do not multiply again without a reason. Invocation count is not a fixed frame rate.
| Name | Type | Default |
|---|---|---|
delta | double | — |
deltaTime advancement in seconds, already scaled by the player.