feature: Added LibMDK video player backend (#162)

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
PartyDonut 2024-11-22 18:53:31 +01:00 committed by GitHub
parent 6e32018183
commit da354437e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 1499 additions and 1006 deletions

View file

@ -20,6 +20,7 @@ class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
@Default(false) bool fillScreen,
@Default(true) bool hardwareAccel,
@Default(false) bool useLibass,
PlayerOptions? playerOptions,
@Default(100) double internalVolume,
Set<DeviceOrientation>? allowedOrientations,
@Default(AutoNextType.smart) AutoNextType nextVideoType,
@ -33,8 +34,10 @@ class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
factory VideoPlayerSettingsModel.fromJson(Map<String, dynamic> json) => _$VideoPlayerSettingsModelFromJson(json);
PlayerOptions get wantedPlayer => playerOptions ?? PlayerOptions.platformDefaults;
bool playerSame(VideoPlayerSettingsModel other) {
return other.hardwareAccel == hardwareAccel && other.useLibass == useLibass;
return other.hardwareAccel == hardwareAccel && other.useLibass == useLibass && other.wantedPlayer == wantedPlayer;
}
@override
@ -48,6 +51,7 @@ class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
other.hardwareAccel == hardwareAccel &&
other.useLibass == useLibass &&
other.internalVolume == internalVolume &&
other.playerOptions == playerOptions &&
other.audioDevice == audioDevice;
}
@ -63,6 +67,27 @@ class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
}
}
enum PlayerOptions {
libMDK,
libMPV;
const PlayerOptions();
static Iterable<PlayerOptions> get available => kIsWeb ? {PlayerOptions.libMPV} : PlayerOptions.values;
static PlayerOptions get platformDefaults {
if (kIsWeb) return PlayerOptions.libMPV;
return switch (defaultTargetPlatform) {
_ => PlayerOptions.libMPV,
};
}
String label(BuildContext context) => switch (this) {
PlayerOptions.libMDK => "MDK",
PlayerOptions.libMPV => "MPV",
};
}
enum AutoNextType {
off,
smart,

View file

@ -26,6 +26,7 @@ mixin _$VideoPlayerSettingsModel {
bool get fillScreen => throw _privateConstructorUsedError;
bool get hardwareAccel => throw _privateConstructorUsedError;
bool get useLibass => throw _privateConstructorUsedError;
PlayerOptions? get playerOptions => throw _privateConstructorUsedError;
double get internalVolume => throw _privateConstructorUsedError;
Set<DeviceOrientation>? get allowedOrientations =>
throw _privateConstructorUsedError;
@ -54,6 +55,7 @@ abstract class $VideoPlayerSettingsModelCopyWith<$Res> {
bool fillScreen,
bool hardwareAccel,
bool useLibass,
PlayerOptions? playerOptions,
double internalVolume,
Set<DeviceOrientation>? allowedOrientations,
AutoNextType nextVideoType,
@ -81,6 +83,7 @@ class _$VideoPlayerSettingsModelCopyWithImpl<$Res,
Object? fillScreen = null,
Object? hardwareAccel = null,
Object? useLibass = null,
Object? playerOptions = freezed,
Object? internalVolume = null,
Object? allowedOrientations = freezed,
Object? nextVideoType = null,
@ -107,6 +110,10 @@ class _$VideoPlayerSettingsModelCopyWithImpl<$Res,
? _value.useLibass
: useLibass // ignore: cast_nullable_to_non_nullable
as bool,
playerOptions: freezed == playerOptions
? _value.playerOptions
: playerOptions // ignore: cast_nullable_to_non_nullable
as PlayerOptions?,
internalVolume: null == internalVolume
? _value.internalVolume
: internalVolume // ignore: cast_nullable_to_non_nullable
@ -142,6 +149,7 @@ abstract class _$$VideoPlayerSettingsModelImplCopyWith<$Res>
bool fillScreen,
bool hardwareAccel,
bool useLibass,
PlayerOptions? playerOptions,
double internalVolume,
Set<DeviceOrientation>? allowedOrientations,
AutoNextType nextVideoType,
@ -168,6 +176,7 @@ class __$$VideoPlayerSettingsModelImplCopyWithImpl<$Res>
Object? fillScreen = null,
Object? hardwareAccel = null,
Object? useLibass = null,
Object? playerOptions = freezed,
Object? internalVolume = null,
Object? allowedOrientations = freezed,
Object? nextVideoType = null,
@ -194,6 +203,10 @@ class __$$VideoPlayerSettingsModelImplCopyWithImpl<$Res>
? _value.useLibass
: useLibass // ignore: cast_nullable_to_non_nullable
as bool,
playerOptions: freezed == playerOptions
? _value.playerOptions
: playerOptions // ignore: cast_nullable_to_non_nullable
as PlayerOptions?,
internalVolume: null == internalVolume
? _value.internalVolume
: internalVolume // ignore: cast_nullable_to_non_nullable
@ -224,6 +237,7 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel
this.fillScreen = false,
this.hardwareAccel = true,
this.useLibass = false,
this.playerOptions,
this.internalVolume = 100,
final Set<DeviceOrientation>? allowedOrientations,
this.nextVideoType = AutoNextType.smart,
@ -249,6 +263,8 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel
@JsonKey()
final bool useLibass;
@override
final PlayerOptions? playerOptions;
@override
@JsonKey()
final double internalVolume;
final Set<DeviceOrientation>? _allowedOrientations;
@ -270,7 +286,7 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'VideoPlayerSettingsModel(screenBrightness: $screenBrightness, videoFit: $videoFit, fillScreen: $fillScreen, hardwareAccel: $hardwareAccel, useLibass: $useLibass, internalVolume: $internalVolume, allowedOrientations: $allowedOrientations, nextVideoType: $nextVideoType, audioDevice: $audioDevice)';
return 'VideoPlayerSettingsModel(screenBrightness: $screenBrightness, videoFit: $videoFit, fillScreen: $fillScreen, hardwareAccel: $hardwareAccel, useLibass: $useLibass, playerOptions: $playerOptions, internalVolume: $internalVolume, allowedOrientations: $allowedOrientations, nextVideoType: $nextVideoType, audioDevice: $audioDevice)';
}
@override
@ -283,6 +299,7 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel
..add(DiagnosticsProperty('fillScreen', fillScreen))
..add(DiagnosticsProperty('hardwareAccel', hardwareAccel))
..add(DiagnosticsProperty('useLibass', useLibass))
..add(DiagnosticsProperty('playerOptions', playerOptions))
..add(DiagnosticsProperty('internalVolume', internalVolume))
..add(DiagnosticsProperty('allowedOrientations', allowedOrientations))
..add(DiagnosticsProperty('nextVideoType', nextVideoType))
@ -313,6 +330,7 @@ abstract class _VideoPlayerSettingsModel extends VideoPlayerSettingsModel {
final bool fillScreen,
final bool hardwareAccel,
final bool useLibass,
final PlayerOptions? playerOptions,
final double internalVolume,
final Set<DeviceOrientation>? allowedOrientations,
final AutoNextType nextVideoType,
@ -333,6 +351,8 @@ abstract class _VideoPlayerSettingsModel extends VideoPlayerSettingsModel {
@override
bool get useLibass;
@override
PlayerOptions? get playerOptions;
@override
double get internalVolume;
@override
Set<DeviceOrientation>? get allowedOrientations;

View file

@ -15,6 +15,8 @@ _$VideoPlayerSettingsModelImpl _$$VideoPlayerSettingsModelImplFromJson(
fillScreen: json['fillScreen'] as bool? ?? false,
hardwareAccel: json['hardwareAccel'] as bool? ?? true,
useLibass: json['useLibass'] as bool? ?? false,
playerOptions:
$enumDecodeNullable(_$PlayerOptionsEnumMap, json['playerOptions']),
internalVolume: (json['internalVolume'] as num?)?.toDouble() ?? 100,
allowedOrientations: (json['allowedOrientations'] as List<dynamic>?)
?.map((e) => $enumDecode(_$DeviceOrientationEnumMap, e))
@ -33,6 +35,7 @@ Map<String, dynamic> _$$VideoPlayerSettingsModelImplToJson(
'fillScreen': instance.fillScreen,
'hardwareAccel': instance.hardwareAccel,
'useLibass': instance.useLibass,
'playerOptions': _$PlayerOptionsEnumMap[instance.playerOptions],
'internalVolume': instance.internalVolume,
'allowedOrientations': instance.allowedOrientations
?.map((e) => _$DeviceOrientationEnumMap[e]!)
@ -51,6 +54,11 @@ const _$BoxFitEnumMap = {
BoxFit.scaleDown: 'scaleDown',
};
const _$PlayerOptionsEnumMap = {
PlayerOptions.libMDK: 'libMDK',
PlayerOptions.libMPV: 'libMPV',
};
const _$DeviceOrientationEnumMap = {
DeviceOrientation.portraitUp: 'portraitUp',
DeviceOrientation.landscapeLeft: 'landscapeLeft',