2020-06-03 23:02:21 +02:00
|
|
|
import 'dart:collection';
|
|
|
|
|
2020-11-06 22:46:47 +01:00
|
|
|
import 'closed_caption_format.dart';
|
2020-06-05 16:17:08 +02:00
|
|
|
import 'closed_caption_track_info.dart';
|
2020-06-03 23:02:21 +02:00
|
|
|
|
|
|
|
/// Manifest that contains information about available closed caption tracks
|
|
|
|
/// in a specific video.
|
|
|
|
class ClosedCaptionManifest {
|
|
|
|
/// Available closed caption tracks.
|
|
|
|
final UnmodifiableListView<ClosedCaptionTrackInfo> tracks;
|
|
|
|
|
|
|
|
/// Initializes an instance of [ClosedCaptionManifest]
|
|
|
|
ClosedCaptionManifest(Iterable<ClosedCaptionTrackInfo> tracks)
|
|
|
|
: tracks = UnmodifiableListView(tracks);
|
|
|
|
|
2020-11-02 13:03:56 +01:00
|
|
|
/// Gets all the closed caption tracks in the specified language and format.
|
2020-12-30 15:00:11 +01:00
|
|
|
/// If [autoGenerated] is true auto generated tracks are included as well.
|
2020-11-02 13:03:56 +01:00
|
|
|
/// Returns an empty list of no track is found.
|
|
|
|
List<ClosedCaptionTrackInfo> getByLanguage(String language,
|
2021-03-11 14:20:10 +01:00
|
|
|
{ClosedCaptionFormat? format, bool autoGenerated = false}) {
|
2020-06-03 23:02:21 +02:00
|
|
|
language = language.toLowerCase();
|
2020-11-02 13:03:56 +01:00
|
|
|
return tracks
|
|
|
|
.where((e) =>
|
|
|
|
(e.language.code.toLowerCase() == language ||
|
|
|
|
e.language.name.toLowerCase() == language) &&
|
2020-12-30 15:00:11 +01:00
|
|
|
(format == null || e.format == format) &&
|
|
|
|
(!autoGenerated || e.isAutoGenerated))
|
2020-11-02 13:03:56 +01:00
|
|
|
.toList();
|
2020-06-03 23:02:21 +02:00
|
|
|
}
|
|
|
|
}
|