startCustomTrack()

startCustomTrack({ track, mode, trackName })

Compatibility:
Prebuilt
Custom

Starts to share a custom track with all the other participants in the meeting.

Arguments:

  • track: a raw MediaStreamTrack object.
  • mode: optional property. Takes the same values as specified in micAudioMode.
  • trackName: optional property. The trackName is an identifier for the custom track.

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 same trackName, 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 trackName that matches one of the following reserved names: "cam-audio", "cam-video", "screen-video", "screen-audio", "rmpAudio", "rmpVideo".
  • If you pass a trackName with more than 50 characters.
  • If you provide a track that is not an instance of MediaStreamTrack