getVideoTracks method

Future<List<VideoTrack>> getVideoTracks()

Gets the available video tracks for the video.

The returned list contains a VideoTrack for each track available for selection.

For adaptive streams such as HLS or DASH, these often correspond to different quality levels with different resolutions or bitrates. For non-adaptive videos (MP4, MOV, etc.), platform implementations may return one or more tracks, or an empty list, depending on the asset and the metadata available.

Note: On iOS 13-14, this returns an empty list as the AVAssetVariant API requires iOS 15+. On web, this throws an UnimplementedError.

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

Implementation

Future<List<VideoTrack>> getVideoTracks() async {
  if (_isDisposedOrNotInitialized) {
    return <VideoTrack>[];
  }
  final List<platform_interface.VideoTrack> platformTracks = await _videoPlayerPlatform
      .getVideoTracks(_playerId);
  return platformTracks
      .map((platform_interface.VideoTrack track) => VideoTrack._fromPlatform(track))
      .toList();
}