2020-02-24 14:28:52 +01:00
|
|
|
import 'package:equatable/equatable.dart';
|
2020-11-13 09:21:01 +01:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
2020-02-24 14:28:52 +01:00
|
|
|
|
2020-11-02 13:03:56 +01:00
|
|
|
import '../../extensions/helpers_extension.dart';
|
2020-11-06 22:46:47 +01:00
|
|
|
import 'closed_caption_format.dart';
|
2020-06-03 23:02:21 +02:00
|
|
|
import 'language.dart';
|
2020-02-23 20:29:08 +01:00
|
|
|
|
2020-11-13 09:21:01 +01:00
|
|
|
part 'closed_caption_track_info.g.dart';
|
|
|
|
|
2020-02-23 20:29:08 +01:00
|
|
|
/// Metadata associated with a certain [ClosedCaptionTrack]
|
2020-11-13 09:21:01 +01:00
|
|
|
@JsonSerializable()
|
2020-02-24 14:28:52 +01:00
|
|
|
class ClosedCaptionTrackInfo extends Equatable {
|
2020-02-23 20:29:08 +01:00
|
|
|
/// Manifest URL of the associated track.
|
|
|
|
final Uri url;
|
|
|
|
|
2020-02-23 21:00:35 +01:00
|
|
|
/// Language of the associated track.
|
2020-02-23 20:29:08 +01:00
|
|
|
final Language language;
|
|
|
|
|
2020-02-23 21:00:35 +01:00
|
|
|
/// Whether the associated track was automatically generated.
|
2020-02-23 20:29:08 +01:00
|
|
|
final bool isAutoGenerated;
|
|
|
|
|
2020-11-01 15:05:19 +01:00
|
|
|
/// Track format
|
|
|
|
final ClosedCaptionFormat format;
|
|
|
|
|
2020-02-23 21:00:35 +01:00
|
|
|
/// Initializes an instance of [ClosedCaptionTrackInfo]
|
2020-11-01 15:05:19 +01:00
|
|
|
const ClosedCaptionTrackInfo(this.url, this.language,
|
2021-03-11 14:20:10 +01:00
|
|
|
{this.isAutoGenerated = false, required this.format});
|
2020-02-24 14:28:52 +01:00
|
|
|
|
2020-11-02 13:03:56 +01:00
|
|
|
/// Returns this auto-translated to another language.
|
|
|
|
/// Keeping the same format.
|
2020-11-13 09:21:01 +01:00
|
|
|
ClosedCaptionTrackInfo autoTranslate(String lang) {
|
2020-11-02 13:03:56 +01:00
|
|
|
return ClosedCaptionTrackInfo(
|
2020-12-30 15:00:11 +01:00
|
|
|
url.replaceQueryParameters({'tlang': lang}), Language(lang, lang),
|
2020-11-16 11:52:26 +01:00
|
|
|
isAutoGenerated: isAutoGenerated, format: format);
|
2020-11-02 13:03:56 +01:00
|
|
|
}
|
|
|
|
|
2020-06-03 23:02:21 +02:00
|
|
|
@override
|
|
|
|
String toString() => 'CC Track ($language)';
|
|
|
|
|
2020-02-24 14:28:52 +01:00
|
|
|
@override
|
|
|
|
List<Object> get props => [url, language, isAutoGenerated];
|
2020-11-13 09:21:01 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
factory ClosedCaptionTrackInfo.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$ClosedCaptionTrackInfoFromJson(json);
|
|
|
|
|
|
|
|
///
|
|
|
|
Map<String, dynamic> toJson() => _$ClosedCaptionTrackInfoToJson(this);
|
2020-02-23 21:00:35 +01:00
|
|
|
}
|