selectAudioTrack method

Future<void> selectAudioTrack(
  1. String trackId
)
inherited

Selects which audio track is chosen for playback from its trackId

The trackId should match the ID of one of the tracks returned by getAudioTracks. If the track ID is not found or invalid, the platform may ignore the request or throw an exception.

Throws an error if the video player is disposed or not initialized.

Implementation

Future<void> selectAudioTrack(String trackId) async {
  if (_isDisposedOrNotInitialized) {
    throw StateError('VideoPlayerController is disposed or not initialized');
  }
  // The platform implementation (e.g., Android) will wait for the track
  // selection to complete by listening to platform-specific events
  await _videoPlayerPlatform.selectAudioTrack(_playerId, trackId);
}