selectVideoTrack method

Future<void> selectVideoTrack(
  1. VideoTrack? track
)

Selects which video track is chosen for playback.

Pass a VideoTrack to select a specific track. Pass null to clear any manual selection and allow automatic selection.

On iOS, this sets preferredPeakBitRate on the AVPlayerItem. On Android, this uses ExoPlayer's track selection override. On web, this throws an UnimplementedError.

Check isVideoTrackSupportAvailable before calling this method to ensure the platform supports video track selection.

Implementation

Future<void> selectVideoTrack(VideoTrack? track) async {
  if (_isDisposedOrNotInitialized) {
    return;
  }
  // Convert app-facing VideoTrack to platform interface VideoTrack
  final platform_interface.VideoTrack? platformTrack = track != null
      ? platform_interface.VideoTrack(
          id: track.id,
          isSelected: track.isSelected,
          label: track.label,
          bitrate: track.bitrate,
          width: track.width,
          height: track.height,
          frameRate: track.frameRate,
          codec: track.codec,
        )
      : null;
  await _videoPlayerPlatform.selectVideoTrack(_playerId, platformTrack);
}