mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feature: Added settings to force the player into certain orientations (#108)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
691293648b
commit
c32f71b368
11 changed files with 170 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
|
@ -20,6 +21,7 @@ class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
|
|||
@Default(true) bool hardwareAccel,
|
||||
@Default(false) bool useLibass,
|
||||
@Default(100) double internalVolume,
|
||||
Set<DeviceOrientation>? allowedOrientations,
|
||||
@Default(AutoNextType.static) AutoNextType nextVideoType,
|
||||
String? audioDevice,
|
||||
}) = _VideoPlayerSettingsModel;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ mixin _$VideoPlayerSettingsModel {
|
|||
bool get hardwareAccel => throw _privateConstructorUsedError;
|
||||
bool get useLibass => throw _privateConstructorUsedError;
|
||||
double get internalVolume => throw _privateConstructorUsedError;
|
||||
Set<DeviceOrientation>? get allowedOrientations =>
|
||||
throw _privateConstructorUsedError;
|
||||
AutoNextType get nextVideoType => throw _privateConstructorUsedError;
|
||||
String? get audioDevice => throw _privateConstructorUsedError;
|
||||
|
||||
|
|
@ -53,6 +55,7 @@ abstract class $VideoPlayerSettingsModelCopyWith<$Res> {
|
|||
bool hardwareAccel,
|
||||
bool useLibass,
|
||||
double internalVolume,
|
||||
Set<DeviceOrientation>? allowedOrientations,
|
||||
AutoNextType nextVideoType,
|
||||
String? audioDevice});
|
||||
}
|
||||
|
|
@ -79,6 +82,7 @@ class _$VideoPlayerSettingsModelCopyWithImpl<$Res,
|
|||
Object? hardwareAccel = null,
|
||||
Object? useLibass = null,
|
||||
Object? internalVolume = null,
|
||||
Object? allowedOrientations = freezed,
|
||||
Object? nextVideoType = null,
|
||||
Object? audioDevice = freezed,
|
||||
}) {
|
||||
|
|
@ -107,6 +111,10 @@ class _$VideoPlayerSettingsModelCopyWithImpl<$Res,
|
|||
? _value.internalVolume
|
||||
: internalVolume // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
allowedOrientations: freezed == allowedOrientations
|
||||
? _value.allowedOrientations
|
||||
: allowedOrientations // ignore: cast_nullable_to_non_nullable
|
||||
as Set<DeviceOrientation>?,
|
||||
nextVideoType: null == nextVideoType
|
||||
? _value.nextVideoType
|
||||
: nextVideoType // ignore: cast_nullable_to_non_nullable
|
||||
|
|
@ -135,6 +143,7 @@ abstract class _$$VideoPlayerSettingsModelImplCopyWith<$Res>
|
|||
bool hardwareAccel,
|
||||
bool useLibass,
|
||||
double internalVolume,
|
||||
Set<DeviceOrientation>? allowedOrientations,
|
||||
AutoNextType nextVideoType,
|
||||
String? audioDevice});
|
||||
}
|
||||
|
|
@ -160,6 +169,7 @@ class __$$VideoPlayerSettingsModelImplCopyWithImpl<$Res>
|
|||
Object? hardwareAccel = null,
|
||||
Object? useLibass = null,
|
||||
Object? internalVolume = null,
|
||||
Object? allowedOrientations = freezed,
|
||||
Object? nextVideoType = null,
|
||||
Object? audioDevice = freezed,
|
||||
}) {
|
||||
|
|
@ -188,6 +198,10 @@ class __$$VideoPlayerSettingsModelImplCopyWithImpl<$Res>
|
|||
? _value.internalVolume
|
||||
: internalVolume // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
allowedOrientations: freezed == allowedOrientations
|
||||
? _value._allowedOrientations
|
||||
: allowedOrientations // ignore: cast_nullable_to_non_nullable
|
||||
as Set<DeviceOrientation>?,
|
||||
nextVideoType: null == nextVideoType
|
||||
? _value.nextVideoType
|
||||
: nextVideoType // ignore: cast_nullable_to_non_nullable
|
||||
|
|
@ -211,9 +225,11 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel
|
|||
this.hardwareAccel = true,
|
||||
this.useLibass = false,
|
||||
this.internalVolume = 100,
|
||||
final Set<DeviceOrientation>? allowedOrientations,
|
||||
this.nextVideoType = AutoNextType.static,
|
||||
this.audioDevice})
|
||||
: super._();
|
||||
: _allowedOrientations = allowedOrientations,
|
||||
super._();
|
||||
|
||||
factory _$VideoPlayerSettingsModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$VideoPlayerSettingsModelImplFromJson(json);
|
||||
|
|
@ -235,6 +251,17 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel
|
|||
@override
|
||||
@JsonKey()
|
||||
final double internalVolume;
|
||||
final Set<DeviceOrientation>? _allowedOrientations;
|
||||
@override
|
||||
Set<DeviceOrientation>? get allowedOrientations {
|
||||
final value = _allowedOrientations;
|
||||
if (value == null) return null;
|
||||
if (_allowedOrientations is EqualUnmodifiableSetView)
|
||||
return _allowedOrientations;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableSetView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final AutoNextType nextVideoType;
|
||||
|
|
@ -243,7 +270,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, nextVideoType: $nextVideoType, audioDevice: $audioDevice)';
|
||||
return 'VideoPlayerSettingsModel(screenBrightness: $screenBrightness, videoFit: $videoFit, fillScreen: $fillScreen, hardwareAccel: $hardwareAccel, useLibass: $useLibass, internalVolume: $internalVolume, allowedOrientations: $allowedOrientations, nextVideoType: $nextVideoType, audioDevice: $audioDevice)';
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -257,6 +284,7 @@ class _$VideoPlayerSettingsModelImpl extends _VideoPlayerSettingsModel
|
|||
..add(DiagnosticsProperty('hardwareAccel', hardwareAccel))
|
||||
..add(DiagnosticsProperty('useLibass', useLibass))
|
||||
..add(DiagnosticsProperty('internalVolume', internalVolume))
|
||||
..add(DiagnosticsProperty('allowedOrientations', allowedOrientations))
|
||||
..add(DiagnosticsProperty('nextVideoType', nextVideoType))
|
||||
..add(DiagnosticsProperty('audioDevice', audioDevice));
|
||||
}
|
||||
|
|
@ -286,6 +314,7 @@ abstract class _VideoPlayerSettingsModel extends VideoPlayerSettingsModel {
|
|||
final bool hardwareAccel,
|
||||
final bool useLibass,
|
||||
final double internalVolume,
|
||||
final Set<DeviceOrientation>? allowedOrientations,
|
||||
final AutoNextType nextVideoType,
|
||||
final String? audioDevice}) = _$VideoPlayerSettingsModelImpl;
|
||||
_VideoPlayerSettingsModel._() : super._();
|
||||
|
|
@ -306,6 +335,8 @@ abstract class _VideoPlayerSettingsModel extends VideoPlayerSettingsModel {
|
|||
@override
|
||||
double get internalVolume;
|
||||
@override
|
||||
Set<DeviceOrientation>? get allowedOrientations;
|
||||
@override
|
||||
AutoNextType get nextVideoType;
|
||||
@override
|
||||
String? get audioDevice;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ _$VideoPlayerSettingsModelImpl _$$VideoPlayerSettingsModelImplFromJson(
|
|||
hardwareAccel: json['hardwareAccel'] as bool? ?? true,
|
||||
useLibass: json['useLibass'] as bool? ?? false,
|
||||
internalVolume: (json['internalVolume'] as num?)?.toDouble() ?? 100,
|
||||
allowedOrientations: (json['allowedOrientations'] as List<dynamic>?)
|
||||
?.map((e) => $enumDecode(_$DeviceOrientationEnumMap, e))
|
||||
.toSet(),
|
||||
nextVideoType:
|
||||
$enumDecodeNullable(_$AutoNextTypeEnumMap, json['nextVideoType']) ??
|
||||
AutoNextType.static,
|
||||
|
|
@ -31,6 +34,9 @@ Map<String, dynamic> _$$VideoPlayerSettingsModelImplToJson(
|
|||
'hardwareAccel': instance.hardwareAccel,
|
||||
'useLibass': instance.useLibass,
|
||||
'internalVolume': instance.internalVolume,
|
||||
'allowedOrientations': instance.allowedOrientations
|
||||
?.map((e) => _$DeviceOrientationEnumMap[e]!)
|
||||
.toList(),
|
||||
'nextVideoType': _$AutoNextTypeEnumMap[instance.nextVideoType]!,
|
||||
'audioDevice': instance.audioDevice,
|
||||
};
|
||||
|
|
@ -45,6 +51,13 @@ const _$BoxFitEnumMap = {
|
|||
BoxFit.scaleDown: 'scaleDown',
|
||||
};
|
||||
|
||||
const _$DeviceOrientationEnumMap = {
|
||||
DeviceOrientation.portraitUp: 'portraitUp',
|
||||
DeviceOrientation.landscapeLeft: 'landscapeLeft',
|
||||
DeviceOrientation.portraitDown: 'portraitDown',
|
||||
DeviceOrientation.landscapeRight: 'landscapeRight',
|
||||
};
|
||||
|
||||
const _$AutoNextTypeEnumMap = {
|
||||
AutoNextType.off: 'off',
|
||||
AutoNextType.smart: 'smart',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue