Skip to content

Class: Track ​

Constructors ​

Constructor ​

ts
new Track(opts): Track;

Parameters ​

ParameterType
optsTrackOptions

Returns ​

Track

Properties ​

PropertyModifierType
isLocalreadonlyboolean
kindreadonlyTrackKind
participantIdentityreadonlystring
sourcereadonlyTrackSource

Accessors ​

display ​

Get Signature ​

ts
get display(): TrackDisplay;

What the host last said about how this track is shown.

Returns ​

TrackDisplay


enabled ​

Get Signature ​

ts
get enabled(): boolean;

True when the track is producing. A muted local track is still attached and still on the wire — it simply carries silence or black.

Returns ​

boolean


id ​

Get Signature ​

ts
get id(): string;
Returns ​

string


mediaStreamTrack ​

Get Signature ​

ts
get mediaStreamTrack(): MediaStreamTrack;
Returns ​

MediaStreamTrack


sid ​

Get Signature ​

ts
get sid(): string;

The platform's TR_ sid. A local track in an sfu room gets one once PublishTrack has reserved it, which is after the capture it wraps exists; empty until then, and always empty in a p2p room.

Returns ​

string

Methods ​

attach() ​

ts
attach(element?): HTMLMediaElement;

Parameters ​

ParameterType
element?HTMLMediaElement

Returns ​

HTMLMediaElement


detach() ​

ts
detach(element?): void;

Parameters ​

ParameterType
element?HTMLMediaElement

Returns ​

void


ref() ​

ts
readonly ref(element): void;

A ref callback, so the common case in React is <video ref={track.ref} /> and there is no effect to write, no dependency array to get wrong and no cleanup to forget. Bound once and stable, because a new function identity every render makes React detach and reattach on every render.

Parameters ​

ParameterType
elementHTMLMediaElement | null

Returns ​

void


resume() ​

ts
resume(): Promise<void>;

Retries every attached element after a user gesture.

Returns ​

Promise<void>


setDisplay() ​

ts
setDisplay(display): void;

Tell the SDK how this remote track is shown, so an sfu room sends only what is seen: an off-screen tile is paused, and a thumbnail is sent a thumbnail's worth. Resuming is immediate and renegotiates nothing. @talkline/react's useVisibleTile calls this from the element's own visibility and size, which is the common case.

Parameters ​

ParameterType
displayTrackDisplay

Returns ​

void


setSinkId() ​

ts
setSinkId(deviceId): Promise<void>;

Output-device selection, which is setSinkId and is not everywhere: Firefox has it behind a preference and Safari does not have it at all. Refusing loudly beats a silent no-op that leaves a user wondering why the speaker they chose is not the one making noise.

Parameters ​

ParameterType
deviceIdstring

Returns ​

Promise<void>


stop() ​

ts
stop(): void;

Stops the underlying track. Local only — stopping a remote track just blinds this end without telling anybody.

Returns ​

void


swap() ​

ts
swap(next): void;

A device change swaps the underlying track and every element already showing it follows, because they hold the same MediaStream object and it is the stream's contents that changed.

Parameters ​

ParameterType
nextMediaStreamTrack

Returns ​

void

Talkline documentation