youtube_explode/lib/src/videos/closed_captions/closed_caption_track.dart

19 lines
623 B
Dart
Raw Normal View History

2020-06-03 23:02:21 +02:00
import 'dart:collection';
import 'closed_caption.dart';
/// Track that contains closed captions in a specific language.
class ClosedCaptionTrack {
/// Closed captions.
final UnmodifiableListView<ClosedCaption> captions;
/// Initializes an instance of [ClosedCaptionTrack].
ClosedCaptionTrack(Iterable<ClosedCaption> captions)
: captions = UnmodifiableListView(captions);
/// Gets the caption displayed at the specified point in time.
/// Returns null if not found.
ClosedCaption getByTime(Duration time) => captions
.firstWhere((e) => time >= e.offset && time <= e.end, orElse: () => null);
2020-06-03 23:02:21 +02:00
}