getTracks method

Future<List<LocalMediaTrack>> getTracks({
  1. AudioPreferences? audio,
  2. VideoPreferences? video,
  3. ScreenPreferences? screen,
})

Returns LocalMediaTracks of the audio, video and screen devices.

Implementation

Future<List<LocalMediaTrack>> getTracks({
  AudioPreferences? audio,
  VideoPreferences? video,
  ScreenPreferences? screen,
}) async {
  if (_mediaManager == null) {
    return [];
  }

  final List<LocalMediaTrack> tracks = [];

  if (audio != null || video != null || screen != null) {
    final List<LocalMediaTrack>? local = await (await _mediaManager)
        ?.initLocalTracks(
          _mediaStreamSettings(audio: audio, video: video, screen: screen),
        );

    if (local != null) {
      tracks.addAll(local);
    }
  }

  return tracks;
}