SourceBuffer Class
A source buffer of a MediaSource (https://w3c.github.io/media-source/#sourcebuffer): the scripts append the initialization segments and the media segments of a byte stream, which the media backend parses (MediaSegmentParser). The library keeps the position of the coded frames on the media timeline (not their data) in the track buffers, as specified: the coded frame processing algorithm (SourceBuffer.TimestampOffset, SourceBuffer.Mode, the append window, the coded frame groups, the frames that overlap), the removals, the eviction when the buffer is full, and the SourceBuffer.Buffered ranges.
public class SourceBuffer : EventTarget- Inheritance
EventTargetSourceBuffer
Properties
| Name | Description |
|---|---|
| AppendWindowEnd | Gets or sets the end of the append window, in seconds (https://w3c.github.io/media-source/#dom-sourcebuffer-appendwindowend): the coded frames that end after it are dropped. |
| AppendWindowStart | Gets or sets the start of the append window, in seconds (https://w3c.github.io/media-source/#dom-sourcebuffer-appendwindowstart): the coded frames that start before it are dropped. |
| AudioTracks | Gets the audio tracks created by the source buffer (https://w3c.github.io/media-source/#dom-sourcebuffer-audiotracks). |
| Buffered | Gets the time ranges that are buffered (https://w3c.github.io/media-source/#dom-sourcebuffer-buffered): the intersection of the ranges of the audio and video track buffers. The same object is returned while the ranges do not change. Throws an InvalidStateError when the source buffer is removed. |
| Mode | Gets or sets how the media segments are placed on the media timeline (https://w3c.github.io/media-source/#dom-sourcebuffer-mode). The setter throws an InvalidStateError when the source buffer is removed, is updating or is parsing a media segment, and a TypeError when the timestamps of the byte stream format are generated (the mode is always AppendMode.Sequence). |
| OnAbort | Gets or sets the event handler of the abort event. |
| OnError | Gets or sets the event handler of the error event. |
| OnUpdate | Gets or sets the event handler of the update event. |
| OnUpdateEnd | Gets or sets the event handler of the updateend event. |
| OnUpdateStart | Gets or sets the event handler of the updatestart event. |
| TextTracks | Gets the text tracks created by the source buffer (https://w3c.github.io/media-source/#dom-sourcebuffer-texttracks): the list is always empty (the text tracks of the byte streams are not supported, as in the browsers). |
| TimestampOffset | Gets or sets the offset applied to the timestamps of the next media segments, in seconds (https://w3c.github.io/media-source/#dom-sourcebuffer-timestampoffset). |
| Updating | Gets a value indicating whether an append or a removal is being processed (https://w3c.github.io/media-source/#dom-sourcebuffer-updating). |
| VideoTracks | Gets the video tracks created by the source buffer (https://w3c.github.io/media-source/#dom-sourcebuffer-videotracks). |
AppendWindowEnd
SourceBuffer.csGets or sets the end of the append window, in seconds (https://w3c.github.io/media-source/#dom-sourcebuffer-appendwindowend): the coded frames that end after it are dropped.
public double AppendWindowEnd { get; set; }AppendWindowStart
SourceBuffer.csGets or sets the start of the append window, in seconds (https://w3c.github.io/media-source/#dom-sourcebuffer-appendwindowstart): the coded frames that start before it are dropped.
public double AppendWindowStart { get; set; }AudioTracks
SourceBuffer.csGets the audio tracks created by the source buffer (https://w3c.github.io/media-source/#dom-sourcebuffer-audiotracks).
public AudioTrackList AudioTracks { get; }Property value
See also
Buffered
SourceBuffer.csGets the time ranges that are buffered (https://w3c.github.io/media-source/#dom-sourcebuffer-buffered): the intersection of the ranges of the audio and video track buffers. The same object is returned while the ranges do not change. Throws an InvalidStateError when the source buffer is removed.
public TimeRanges Buffered { get; }Mode
SourceBuffer.csGets or sets how the media segments are placed on the media timeline (https://w3c.github.io/media-source/#dom-sourcebuffer-mode). The setter throws an InvalidStateError when the source buffer is removed, is updating or is parsing a media segment, and a TypeError when the timestamps of the byte stream format are generated (the mode is always AppendMode.Sequence).
public AppendMode Mode { get; set; }OnAbort
SourceBuffer.csGets or sets the event handler of the abort event.
OnError
SourceBuffer.csGets or sets the event handler of the error event.
OnUpdate
SourceBuffer.csGets or sets the event handler of the update event.
OnUpdateEnd
SourceBuffer.csGets or sets the event handler of the updateend event.
Property value
See also
OnUpdateStart
SourceBuffer.csGets or sets the event handler of the updatestart event.
Property value
See also
TextTracks
SourceBuffer.csGets the text tracks created by the source buffer (https://w3c.github.io/media-source/#dom-sourcebuffer-texttracks): the list is always empty (the text tracks of the byte streams are not supported, as in the browsers).
public TextTrackList TextTracks { get; }TimestampOffset
SourceBuffer.csGets or sets the offset applied to the timestamps of the next media segments, in seconds (https://w3c.github.io/media-source/#dom-sourcebuffer-timestampoffset).
public double TimestampOffset { get; set; }Updating
SourceBuffer.csGets a value indicating whether an append or a removal is being processed (https://w3c.github.io/media-source/#dom-sourcebuffer-updating).
public bool Updating { get; }VideoTracks
SourceBuffer.csGets the video tracks created by the source buffer (https://w3c.github.io/media-source/#dom-sourcebuffer-videotracks).
public VideoTrackList VideoTracks { get; }Property value
See also
Methods
| Name | Description |
|---|---|
| Abort() | Aborts the current segment and resets the segment parser (https://w3c.github.io/media-source/#dom-sourcebuffer-abort): a pending append is aborted (abort, updateend), and the append window is reset. |
| AppendBuffer(ReadOnlySpan<byte>) | Appends segment data (https://w3c.github.io/media-source/#dom-sourcebuffer-appendbuffer): the data is parsed in a task (updatestart, then update or error, then updateend). Throws an InvalidStateError when the source buffer is removed or updating, or when the media element has an error, and a QuotaExceededError when the buffer is full. |
| ChangeType(string) | Changes the MIME type of the next appended bytes (https://w3c.github.io/media-source/#dom-sourcebuffer-changetype): the next segment must be an initialization segment. Throws a TypeError for an empty type and a NotSupportedError when the media backend does not support the type. |
| Remove(double, double) | Removes the media of a time range (https://w3c.github.io/media-source/#dom-sourcebuffer-remove), in a task (updatestart, update, updateend). |
Abort()
SourceBuffer.csAborts the current segment and resets the segment parser (https://w3c.github.io/media-source/#dom-sourcebuffer-abort): a pending append is aborted (abort, updateend), and the append window is reset.
public void Abort()AppendBuffer(ReadOnlySpan<byte>)
SourceBuffer.csAppends segment data (https://w3c.github.io/media-source/#dom-sourcebuffer-appendbuffer): the data is parsed in a task (updatestart, then update or error, then updateend). Throws an InvalidStateError when the source buffer is removed or updating, or when the media element has an error, and a QuotaExceededError when the buffer is full.
public void AppendBuffer(ReadOnlySpan<byte> data)ChangeType(string)
SourceBuffer.csChanges the MIME type of the next appended bytes (https://w3c.github.io/media-source/#dom-sourcebuffer-changetype): the next segment must be an initialization segment. Throws a TypeError for an empty type and a NotSupportedError when the media backend does not support the type.