startCustomTrack()
startCustomTrack({ track, mode, trackName, ignoreAudioLevel })
Compatibility:
Prebuilt
Custom
Starts to share a custom track with all the other participants in the meeting.
Arguments:
track: a rawMediaStreamTrackobject.mode: optional property. Takes the same values as specified inmicAudioMode.trackName: optional property. ThetrackNameis an identifier for the custom track.ignoreAudioLevel: optional boolean (defaults tofalse). Iftrue, the track is not considered when generating active speaker events.
startCustomTrack() returns a Promise which resolves with a string identifier for the track.
trackName
- If you have provided a
trackName, it will be used as the returned identifier. - If you don’t provide a
trackName, Daily creates one with the following format:custom$TRACK_KIND$COUNT(eg."customAudio0"or"customVideo1"). - You will use this identifier to subscribe to a custom track and to stop a custom track.
- If you invoke
startCustomTrack()multiple times with the sametrackName, the existing custom track will be replaced.
To confirm that the custom track has started, listen for "participant-updated" events and check the local user's tracks property. A new key will be inside with the identifier of your custom track.
If you are not subscribing to tracks automatically, you can subscribe to all custom tracks or to specific tracks only. See the examples below:
Errors
This method will throw error in the following cases:
- If you try to start a custom track but you are not yet in a meeting.
- If you pass a
trackNamethat matches one of the following reserved names:"cam-audio","cam-video","screen-video","screen-audio","rmpAudio","rmpVideo". - If you pass a
trackNamewith more than 50 characters. - If you provide a
trackthat is not an instance ofMediaStreamTrack