createRenderer method

Future<void> createRenderer()

Creates the renderer for this Track.

Implementation

Future<void> createRenderer() async {
  Log.debug('createRenderer() for $kind-$source', '$runtimeType');

  await _rendererGuard.protect(() async {
    if (renderer.value != null) {
      await renderer.value?.dispose();
    }

    switch (track.kind()) {
      case MediaKind.audio:
        renderer.value = RtcAudioRenderer(track);
        break;

      case MediaKind.video:
        renderer.value = RtcVideoRenderer(track);
        await (renderer.value as RtcVideoRenderer?)?.initialize();
        (renderer.value as RtcVideoRenderer?)?.srcObject = track.getTrack();
        break;
    }
  });
}