mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feat: Enable player orientation for native player on phones
This commit is contained in:
parent
08301b9ad8
commit
83c5fafe46
11 changed files with 197 additions and 68 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
|
|
@ -50,6 +51,16 @@ final pigeonPlayerSettingsSyncProvider = Provider<void>((ref) {
|
|||
},
|
||||
skipBackward: (userData?.userSettings?.skipBackDuration ?? const Duration(seconds: 15)).inMilliseconds,
|
||||
skipForward: (userData?.userSettings?.skipForwardDuration ?? const Duration(seconds: 30)).inMilliseconds,
|
||||
acceptedOrientations: (value.allowedOrientations?.toList() ?? DeviceOrientation.values)
|
||||
.map(
|
||||
(e) => switch (e) {
|
||||
DeviceOrientation.portraitUp => pigeon.PlayerOrientations.portraitUp,
|
||||
DeviceOrientation.portraitDown => pigeon.PlayerOrientations.portraitDown,
|
||||
DeviceOrientation.landscapeLeft => pigeon.PlayerOrientations.landScapeLeft,
|
||||
DeviceOrientation.landscapeRight => pigeon.PlayerOrientations.landScapeRight,
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,17 +408,12 @@ class _PlayerSettingsPageState extends ConsumerState<PlayerSettingsPage> {
|
|||
),
|
||||
],
|
||||
),
|
||||
if (videoSettings.wantedPlayer != PlayerOptions.nativePlayer) ...[
|
||||
if (!AdaptiveLayout.of(context).isDesktop &&
|
||||
!kIsWeb &&
|
||||
!ref.read(argumentsStateProvider).htpcMode &&
|
||||
videoSettings.wantedPlayer != PlayerOptions.nativePlayer)
|
||||
SettingsListTile(
|
||||
label: Text(context.localized.playerSettingsOrientationTitle),
|
||||
subLabel: Text(context.localized.playerSettingsOrientationDesc),
|
||||
onTap: () => showOrientationOptions(context, ref),
|
||||
),
|
||||
],
|
||||
if (!AdaptiveLayout.of(context).isDesktop && !kIsWeb && !ref.read(argumentsStateProvider).htpcMode)
|
||||
SettingsListTile(
|
||||
label: Text(context.localized.playerSettingsOrientationTitle),
|
||||
subLabel: Text(context.localized.playerSettingsOrientationDesc),
|
||||
onTap: () => showOrientationOptions(context, ref),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -29,6 +29,13 @@ bool _deepEquals(Object? a, Object? b) {
|
|||
}
|
||||
|
||||
|
||||
enum PlayerOrientations {
|
||||
portraitUp,
|
||||
portraitDown,
|
||||
landScapeLeft,
|
||||
landScapeRight,
|
||||
}
|
||||
|
||||
enum AutoNextType {
|
||||
off,
|
||||
static,
|
||||
|
|
@ -57,6 +64,7 @@ class PlayerSettings {
|
|||
required this.skipForward,
|
||||
required this.skipBackward,
|
||||
required this.autoNextType,
|
||||
required this.acceptedOrientations,
|
||||
});
|
||||
|
||||
bool enableTunneling;
|
||||
|
|
@ -71,6 +79,8 @@ class PlayerSettings {
|
|||
|
||||
AutoNextType autoNextType;
|
||||
|
||||
List<PlayerOrientations> acceptedOrientations;
|
||||
|
||||
List<Object?> _toList() {
|
||||
return <Object?>[
|
||||
enableTunneling,
|
||||
|
|
@ -79,6 +89,7 @@ class PlayerSettings {
|
|||
skipForward,
|
||||
skipBackward,
|
||||
autoNextType,
|
||||
acceptedOrientations,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +105,7 @@ class PlayerSettings {
|
|||
skipForward: result[3]! as int,
|
||||
skipBackward: result[4]! as int,
|
||||
autoNextType: result[5]! as AutoNextType,
|
||||
acceptedOrientations: (result[6] as List<Object?>?)!.cast<PlayerOrientations>(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -123,17 +135,20 @@ class _PigeonCodec extends StandardMessageCodec {
|
|||
if (value is int) {
|
||||
buffer.putUint8(4);
|
||||
buffer.putInt64(value);
|
||||
} else if (value is AutoNextType) {
|
||||
} else if (value is PlayerOrientations) {
|
||||
buffer.putUint8(129);
|
||||
writeValue(buffer, value.index);
|
||||
} else if (value is SegmentType) {
|
||||
} else if (value is AutoNextType) {
|
||||
buffer.putUint8(130);
|
||||
writeValue(buffer, value.index);
|
||||
} else if (value is SegmentSkip) {
|
||||
} else if (value is SegmentType) {
|
||||
buffer.putUint8(131);
|
||||
writeValue(buffer, value.index);
|
||||
} else if (value is PlayerSettings) {
|
||||
} else if (value is SegmentSkip) {
|
||||
buffer.putUint8(132);
|
||||
writeValue(buffer, value.index);
|
||||
} else if (value is PlayerSettings) {
|
||||
buffer.putUint8(133);
|
||||
writeValue(buffer, value.encode());
|
||||
} else {
|
||||
super.writeValue(buffer, value);
|
||||
|
|
@ -145,14 +160,17 @@ class _PigeonCodec extends StandardMessageCodec {
|
|||
switch (type) {
|
||||
case 129:
|
||||
final int? value = readValue(buffer) as int?;
|
||||
return value == null ? null : AutoNextType.values[value];
|
||||
return value == null ? null : PlayerOrientations.values[value];
|
||||
case 130:
|
||||
final int? value = readValue(buffer) as int?;
|
||||
return value == null ? null : SegmentType.values[value];
|
||||
return value == null ? null : AutoNextType.values[value];
|
||||
case 131:
|
||||
final int? value = readValue(buffer) as int?;
|
||||
return value == null ? null : SegmentSkip.values[value];
|
||||
return value == null ? null : SegmentType.values[value];
|
||||
case 132:
|
||||
final int? value = readValue(buffer) as int?;
|
||||
return value == null ? null : SegmentSkip.values[value];
|
||||
case 133:
|
||||
return PlayerSettings.decode(readValue(buffer)!);
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue