mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feature: Auto next-up preview, skip to next in queue. (#96)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
f72ae9e3ca
commit
66f2b6cd4e
13 changed files with 971 additions and 137 deletions
|
|
@ -1,86 +1,35 @@
|
|||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class VideoPlayerSettingsModel {
|
||||
final double? screenBrightness;
|
||||
final BoxFit videoFit;
|
||||
final bool fillScreen;
|
||||
final bool hardwareAccel;
|
||||
final bool useLibass;
|
||||
final double internalVolume;
|
||||
final String? audioDevice;
|
||||
const VideoPlayerSettingsModel({
|
||||
this.screenBrightness,
|
||||
this.videoFit = BoxFit.contain,
|
||||
this.fillScreen = false,
|
||||
this.hardwareAccel = true,
|
||||
this.useLibass = false,
|
||||
this.internalVolume = 100,
|
||||
this.audioDevice,
|
||||
});
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'package:fladder/util/localization_helper.dart';
|
||||
|
||||
part 'video_player_settings.freezed.dart';
|
||||
part 'video_player_settings.g.dart';
|
||||
|
||||
@freezed
|
||||
class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
|
||||
const VideoPlayerSettingsModel._();
|
||||
|
||||
factory VideoPlayerSettingsModel({
|
||||
double? screenBrightness,
|
||||
@Default(BoxFit.contain) BoxFit videoFit,
|
||||
@Default(false) bool fillScreen,
|
||||
@Default(true) bool hardwareAccel,
|
||||
@Default(false) bool useLibass,
|
||||
@Default(100) double internalVolume,
|
||||
@Default(AutoNextType.static) AutoNextType nextVideoType,
|
||||
String? audioDevice,
|
||||
}) = _VideoPlayerSettingsModel;
|
||||
|
||||
double get volume => switch (defaultTargetPlatform) {
|
||||
TargetPlatform.android || TargetPlatform.iOS => 100,
|
||||
_ => internalVolume,
|
||||
};
|
||||
|
||||
VideoPlayerSettingsModel copyWith({
|
||||
ValueGetter<double?>? screenBrightness,
|
||||
BoxFit? videoFit,
|
||||
bool? fillScreen,
|
||||
bool? hardwareAccel,
|
||||
bool? useLibass,
|
||||
double? internalVolume,
|
||||
ValueGetter<String?>? audioDevice,
|
||||
}) {
|
||||
return VideoPlayerSettingsModel(
|
||||
screenBrightness: screenBrightness != null ? screenBrightness() : this.screenBrightness,
|
||||
videoFit: videoFit ?? this.videoFit,
|
||||
fillScreen: fillScreen ?? this.fillScreen,
|
||||
hardwareAccel: hardwareAccel ?? this.hardwareAccel,
|
||||
useLibass: useLibass ?? this.useLibass,
|
||||
internalVolume: internalVolume ?? this.internalVolume,
|
||||
audioDevice: audioDevice != null ? audioDevice() : this.audioDevice,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'screenBrightness': screenBrightness,
|
||||
'videoFit': videoFit.name,
|
||||
'fillScreen': fillScreen,
|
||||
'hardwareAccel': hardwareAccel,
|
||||
'useLibass': useLibass,
|
||||
'internalVolume': internalVolume,
|
||||
'audioDevice': audioDevice,
|
||||
};
|
||||
}
|
||||
|
||||
factory VideoPlayerSettingsModel.fromMap(Map<String, dynamic> map) {
|
||||
return VideoPlayerSettingsModel(
|
||||
screenBrightness: map['screenBrightness']?.toDouble(),
|
||||
videoFit: BoxFit.values.firstWhereOrNull((element) => element.name == map['videoFit']) ?? BoxFit.contain,
|
||||
fillScreen: map['fillScreen'] ?? false,
|
||||
hardwareAccel: map['hardwareAccel'] ?? false,
|
||||
useLibass: map['useLibass'] ?? false,
|
||||
internalVolume: map['internalVolume']?.toDouble() ?? 0.0,
|
||||
audioDevice: map['audioDevice'],
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory VideoPlayerSettingsModel.fromJson(String source) => VideoPlayerSettingsModel.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'VideoPlayerSettingsModel(screenBrightness: $screenBrightness, videoFit: $videoFit, fillScreen: $fillScreen, hardwareAccel: $hardwareAccel, useLibass: $useLibass, internalVolume: $internalVolume, audioDevice: $audioDevice)';
|
||||
}
|
||||
factory VideoPlayerSettingsModel.fromJson(Map<String, dynamic> json) => _$VideoPlayerSettingsModelFromJson(json);
|
||||
|
||||
bool playerSame(VideoPlayerSettingsModel other) {
|
||||
return other.hardwareAccel == hardwareAccel && other.useLibass == useLibass;
|
||||
|
|
@ -111,3 +60,23 @@ class VideoPlayerSettingsModel {
|
|||
audioDevice.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
enum AutoNextType {
|
||||
off,
|
||||
smart,
|
||||
static;
|
||||
|
||||
const AutoNextType();
|
||||
|
||||
String label(BuildContext context) => switch (this) {
|
||||
AutoNextType.off => context.localized.off,
|
||||
AutoNextType.smart => context.localized.autoNextOffSmartTitle,
|
||||
AutoNextType.static => context.localized.autoNextOffStaticTitle,
|
||||
};
|
||||
|
||||
String desc(BuildContext context) => switch (this) {
|
||||
AutoNextType.off => context.localized.off,
|
||||
AutoNextType.smart => context.localized.autoNextOffSmartDesc,
|
||||
AutoNextType.static => context.localized.autoNextOffStaticDesc,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue