getVideoUrlForQuality method

String getVideoUrlForQuality(
  1. {required StreamManifest manifest,
  2. required VideoQuality quality}
)

Gets the network URL for a certain video quality.

Implementation

String getVideoUrlForQuality({
  required StreamManifest manifest,
  required VideoQuality quality,
}) {
  List<VideoStreamInfo> muxed = manifest.muxed
      .where((e) => e.videoCodec.contains('avc1'))
      .where((e) => e.videoQuality == quality)
      .toList();
  if (muxed.isNotEmpty) {
    return muxed.withHighestBitrate().url.toString();
  }

  return manifest.videoOnly
      .where((e) => e.videoCodec.contains('avc1'))
      .where((e) => e.videoQuality == quality)
      .withHighestBitrate()
      .url
      .toString();
}