getClosedCaptionsManifest method

Future<ClosedCaptionManifest> getClosedCaptionsManifest(
  1. MediaItem item
)

Gets the ClosedCaptionManifest if in cache and fetches it and stores it if otherwise.

Implementation

Future<ClosedCaptionManifest> getClosedCaptionsManifest(
    MediaItem item) async {
  String videoId = VideoId(item.mediaIdentifier).value;

  ClosedCaptionManifest? manifest = _closedCaptionManifestCache[videoId];

  if (manifest == null) {
    manifest = await compute(computeCaptionsManifest, videoId);
    _closedCaptionManifestCache[videoId] = manifest!;
  }

  return manifest;
}