Table of Contents

Class SourceBuffer

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The SourceBuffer interface represents a chunk of media to be passed into an HTMLMediaElement and played, via a MediaSource object. This can be made up of one or several media segments.

[Value("SourceBuffer")]
public class SourceBuffer : EventTarget
Inheritance
SourceBuffer
Derived
Inherited Members

Remarks

Constructors

SourceBuffer()

public SourceBuffer()

Properties

AppendWindowEnd

The appendWindowEnd property of the
SourceBuffer interface controls the timestamp for the end of the append window, a
timestamp range that can be used to filter what media data is appended to the
SourceBuffer. Coded media frames with timestamps within this range will be
appended, whereas those outside the range will be filtered out.

[Value("appendWindowEnd")]
public double AppendWindowEnd { get; set; }

Property Value

double

A double, indicating the end time of the append window, in seconds.

Remarks

The default value of appendWindowEnd is positive infinity.

-MediaSource
-SourceBufferList

See also on MDN

AppendWindowStart

The appendWindowStart property of the
SourceBuffer interface controls the timestamp for the start of the append window, a
timestamp range that can be used to filter what media data is appended to the
SourceBuffer. Coded media frames with timestamps within this range will be
appended, whereas those outside the range will be filtered out.

[Value("appendWindowStart")]
public Number AppendWindowStart { get; set; }

Property Value

Number

A double, indicating the start time of the append window, in seconds.

Remarks

The default value of appendWindowStart is the presentation start time,
which is the beginning time of the playable media.

-MediaSource
-SourceBufferList

See also on MDN

AudioTracks

The audioTracks read-only property of the
SourceBuffer interface returns a list of the audio tracks currently
contained inside the SourceBuffer.

[Value("audioTracks")]
public AudioTrackList AudioTracks { get; }

Property Value

AudioTrackList

An AudioTrackList object.

Remarks

Buffered

The buffered read-only property of the
SourceBuffer interface returns the time ranges that are currently
buffered in the SourceBuffer as a normalized TimeRanges
object.

[Value("buffered")]
public TimeRanges Buffered { get; }

Property Value

TimeRanges

A TimeRanges object.

Remarks

Mode

The mode property of the SourceBuffer
interface controls whether media segments can be appended to the
SourceBuffer in any order, or in a strict sequence.

[Value("mode")]
public AppendMode Mode { get; set; }

Property Value

AppendMode

A string.

Remarks

The two available values are:

The mode value is initially set when the SourceBuffer is created using
MediaSource.addSourceBuffer(). If timestamps already exist for the media
segments, then the value will be set to segments; if they don't, then the
value will be set to sequence.

If you try to set the mode property value to segments when
the initial value is sequence, an exception will be thrown. The existing
segment order must be maintained in sequence mode. You can, however, change
the value from segments to sequence. It just means the play
order will be fixed, and new timestamps generated to reflect this.

This property cannot be changed during while the SourceBuffer is
processing either an AppendBuffer(Union224) or
Remove(Number, double) call.

-MediaSource
-SourceBufferList

See also on MDN

Onabort

[Value("onabort")]
public EventHandlerNonNull Onabort { get; set; }

Property Value

EventHandlerNonNull

Onerror

[Value("onerror")]
public EventHandlerNonNull Onerror { get; set; }

Property Value

EventHandlerNonNull

Onupdate

[Value("onupdate")]
public EventHandlerNonNull Onupdate { get; set; }

Property Value

EventHandlerNonNull

Onupdateend

[Value("onupdateend")]
public EventHandlerNonNull Onupdateend { get; set; }

Property Value

EventHandlerNonNull

Onupdatestart

[Value("onupdatestart")]
public EventHandlerNonNull Onupdatestart { get; set; }

Property Value

EventHandlerNonNull

TextTracks

NOTE
Experimental
The textTracks read-only property of the
SourceBuffer interface returns a list of the text tracks currently
contained inside the SourceBuffer.
[Value("textTracks")]
public TextTrackList TextTracks { get; }

Property Value

TextTrackList

An TextTrackList object.

Remarks

TimestampOffset

The timestampOffset property of the
SourceBuffer interface controls the offset applied to timestamps inside
media segments that are appended to the SourceBuffer.

[Value("timestampOffset")]
public Number TimestampOffset { get; set; }

Property Value

Number

A double, with the offset amount expressed in seconds.

Remarks

The initial value of timestampOffset is 0.

-MediaSource
-SourceBufferList

See also on MDN

Updating

The updating read-only property of the
SourceBuffer interface indicates whether the SourceBuffer is
currently being updated — i.e., whether an AppendBuffer(Union224) or Remove(Number, double)
operation is currently in progress.

[Value("updating")]
public bool Updating { get; }

Property Value

bool

A boolean value.

Remarks

VideoTracks

The videoTracks read-only property of the
SourceBuffer interface returns a list of the video tracks currently
contained inside the SourceBuffer.

[Value("videoTracks")]
public VideoTrackList VideoTracks { get; }

Property Value

VideoTrackList

An VideoTrackList object.

Remarks

Methods

Abort()

The abort() method of the SourceBuffer
interface aborts the current segment and resets the segment parser.

[Value("abort")]
public GlobalObject.Undefined Abort()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

AppendBuffer(Union224)

The appendBuffer() method of the
SourceBuffer interface appends media segment data from an
ArrayBuffer, a TypedArray or a DataView object
to the SourceBuffer.

[Value("appendBuffer")]
public GlobalObject.Undefined AppendBuffer(Union224 data)

Parameters

data Union224

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

ChangeType(string)

The changeType() method of the
SourceBuffer interface sets the MIME type that future calls to
AppendBuffer(Union224) should expect the new media
data to conform to. This makes it possible to change codecs or container type
mid-stream.

[Value("changeType")]
public GlobalObject.Undefined ChangeType(string type)

Parameters

type string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

One scenario in which this is helpful is to support adapting the media source to
changing bandwidth availability, by transitioning from one codec to another as resource
constraints change.

-MediaSource
-SourceBufferList

See also on MDN

Remove(Number, double)

The remove() method of the SourceBuffer
interface removes media segments within a specific time range from the
SourceBuffer. This method can only be called when
Updating equals false. If
SourceBuffer.updating is not equal to false, call
Abort().

[Value("remove")]
public GlobalObject.Undefined Remove(Number start, double end)

Parameters

start Number
end double

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks