getManifest method

Future<ClosedCaptionManifest> getManifest(
  1. dynamic videoId, {
  2. @Deprecated('Not used anymore, use track.isAutoGenerated to see if a track is autogenerated or not.') bool autoGenerated = false,
  3. List<ClosedCaptionFormat> formats = const [ClosedCaptionFormat.srv1, ClosedCaptionFormat.srv2, ClosedCaptionFormat.srv3, ClosedCaptionFormat.ttml, ClosedCaptionFormat.vtt],
})

Gets the manifest that contains information about available closed caption tracks in the specified video.

Implementation

Future<ClosedCaptionManifest> getManifest(
  dynamic videoId, {
  @Deprecated(
    'Not used anymore, use track.isAutoGenerated to see if a track is autogenerated or not.',
  ) // ignore: lines_longer_than_80_chars
  bool autoGenerated = false,
  List<ClosedCaptionFormat> formats = const [
    ClosedCaptionFormat.srv1,
    ClosedCaptionFormat.srv2,
    ClosedCaptionFormat.srv3,
    ClosedCaptionFormat.ttml,
    ClosedCaptionFormat.vtt,
  ],
}) async {
  videoId = VideoId.fromString(videoId);
  final tracks = <ClosedCaptionTrackInfo>{};
  final watchPage =
      await WatchPage.get(_httpClient, (videoId as VideoId).value);
  final playerResponse = watchPage.playerResponse!;

  for (final track in playerResponse.closedCaptionTrack) {
    for (final ext in formats) {
      tracks.add(
        ClosedCaptionTrackInfo(
          Uri.parse(track.url)
              .replaceQueryParameters({'fmt': ext.formatCode}),
          Language(track.languageCode, track.languageName ?? ''),
          isAutoGenerated: track.autoGenerated,
          format: ext,
        ),
      );
    }
  }
  return ClosedCaptionManifest(tracks);
}