fix: Disable media tunneling by default with the option to enable it (#515)

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
PartyDonut 2025-10-04 13:29:55 +02:00 committed by GitHub
parent 3ce0ed6dbc
commit 1942738fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 256 additions and 199 deletions

View file

@ -6,6 +6,7 @@ import 'package:flutter/widgets.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:fladder/models/items/media_segments_model.dart';
import 'package:fladder/models/settings/arguments_model.dart';
import 'package:fladder/models/settings/key_combinations.dart';
import 'package:fladder/util/bitrate_helper.dart';
import 'package:fladder/util/localization_helper.dart';
@ -63,6 +64,7 @@ abstract class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
@Default(false) bool fillScreen,
@Default(true) bool hardwareAccel,
@Default(false) bool useLibass,
@Default(false) bool enableTunneling,
@Default(32) int bufferSize,
PlayerOptions? playerOptions,
@Default(100) double internalVolume,
@ -82,7 +84,8 @@ abstract class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
factory VideoPlayerSettingsModel.fromJson(Map<String, dynamic> json) => _$VideoPlayerSettingsModelFromJson(json);
PlayerOptions get wantedPlayer => playerOptions ?? PlayerOptions.platformDefaults;
PlayerOptions get wantedPlayer =>
leanBackMode ? PlayerOptions.nativePlayer : playerOptions ?? PlayerOptions.platformDefaults;
Map<VideoHotKeys, KeyCombination> get currentShortcuts =>
_defaultVideoHotKeys.map((key, value) => MapEntry(key, hotKeys[key] ?? value));
@ -91,6 +94,7 @@ abstract class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
bool playerSame(VideoPlayerSettingsModel other) {
return other.hardwareAccel == hardwareAccel &&
other.enableTunneling == enableTunneling &&
other.useLibass == useLibass &&
other.bufferSize == bufferSize &&
other.wantedPlayer == wantedPlayer;
@ -106,6 +110,7 @@ abstract class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
other.fillScreen == fillScreen &&
other.hardwareAccel == hardwareAccel &&
other.useLibass == useLibass &&
other.enableTunneling == enableTunneling &&
other.bufferSize == bufferSize &&
other.internalVolume == internalVolume &&
other.playerOptions == playerOptions &&
@ -119,6 +124,7 @@ abstract class VideoPlayerSettingsModel with _$VideoPlayerSettingsModel {
fillScreen.hashCode ^
hardwareAccel.hashCode ^
useLibass.hashCode ^
enableTunneling.hashCode ^
bufferSize.hashCode ^
internalVolume.hashCode ^
audioDevice.hashCode;
@ -132,14 +138,17 @@ enum PlayerOptions {
const PlayerOptions();
static Iterable<PlayerOptions> get available => kIsWeb
? {PlayerOptions.libMPV}
: switch (defaultTargetPlatform) {
TargetPlatform.android => PlayerOptions.values,
_ => {PlayerOptions.libMDK, PlayerOptions.libMPV},
};
static Iterable<PlayerOptions> get available => leanBackMode
? {PlayerOptions.nativePlayer, PlayerOptions.libMPV}
: kIsWeb
? {PlayerOptions.libMPV}
: switch (defaultTargetPlatform) {
TargetPlatform.android => PlayerOptions.values,
_ => {PlayerOptions.libMDK, PlayerOptions.libMPV},
};
static PlayerOptions get platformDefaults {
if (leanBackMode) return PlayerOptions.nativePlayer;
if (kIsWeb) return PlayerOptions.libMPV;
return switch (defaultTargetPlatform) {
_ => PlayerOptions.libMPV,
@ -191,8 +200,10 @@ Map<VideoHotKeys, KeyCombination> get _defaultVideoHotKeys => {
VideoHotKeys.mute => KeyCombination(key: LogicalKeyboardKey.keyM),
VideoHotKeys.volumeUp => KeyCombination(key: LogicalKeyboardKey.arrowUp),
VideoHotKeys.volumeDown => KeyCombination(key: LogicalKeyboardKey.arrowDown),
VideoHotKeys.speedUp => KeyCombination(key: LogicalKeyboardKey.arrowUp, modifier: LogicalKeyboardKey.controlLeft),
VideoHotKeys.speedDown => KeyCombination(key: LogicalKeyboardKey.arrowDown, modifier: LogicalKeyboardKey.controlLeft),
VideoHotKeys.speedUp =>
KeyCombination(key: LogicalKeyboardKey.arrowUp, modifier: LogicalKeyboardKey.controlLeft),
VideoHotKeys.speedDown =>
KeyCombination(key: LogicalKeyboardKey.arrowDown, modifier: LogicalKeyboardKey.controlLeft),
VideoHotKeys.prevVideo =>
KeyCombination(key: LogicalKeyboardKey.keyP, modifier: LogicalKeyboardKey.shiftLeft),
VideoHotKeys.nextVideo =>