ReplaceableTrack
Defined in: relay-sdks/ts/src/replaceable-track.ts:68
A track that the publisher can replace mid-stream, for barge-in: a voice agent talked over replaces its reply track, and listeners drop the old reply’s audio and play the new track. Create one with createReplaceableTrack.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
F extends Frame |
Frame |
Properties
Section titled “Properties”closed
Section titled “closed”readonly closed: boolean;Defined in: relay-sdks/ts/src/replaceable-track.ts:88
True once close ran.
replacements
Section titled “replacements”readonly replacements: number;Defined in: relay-sdks/ts/src/replaceable-track.ts:72
How many times the track has been replaced: 0 while the first track plays.
readonly track: string;Defined in: relay-sdks/ts/src/replaceable-track.ts:70
The current track’s name.
Methods
Section titled “Methods”close()
Section titled “close()”close(): Promise<void>;Defined in: relay-sdks/ts/src/replaceable-track.ts:86
Drop what has not been sent and close the current track. Idempotent; write and replace reject after it.
Returns
Section titled “Returns”Promise<void>
replace()
Section titled “replace()”replace(): Promise<TrackReplacement>;Defined in: relay-sdks/ts/src/replaceable-track.ts:84
Replace the track: register the next track, list it in the catalog in the current track’s place, then drop what the current track has not sent and close it. Resolves once the old track is closed. Frames written from the call on go to the new track.
Returns
Section titled “Returns”Promise<TrackReplacement>
write()
Section titled “write()”write(frame): Promise<FrameOutcome>;Defined in: relay-sdks/ts/src/replaceable-track.ts:78
Send one frame on the current track and say what happened, as FrameWriter.write does. A frame written to a
replacement before the relay has subscribed to it waits (demandWaitMs). A frame of a track that is replaced
before it went out is 'dropped'.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
frame |
F |
Returns
Section titled “Returns”Promise<FrameOutcome>