mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 23:18:16 -07:00
fix: Web and input device switching in video player
This commit is contained in:
parent
1eeecdc18f
commit
3b4eec6c4f
5 changed files with 110 additions and 63 deletions
|
|
@ -13,6 +13,7 @@ import 'package:fladder/screens/video_player/components/video_player_next_wrappe
|
|||
import 'package:fladder/screens/video_player/video_player_controls.dart';
|
||||
import 'package:fladder/util/adaptive_layout/adaptive_layout.dart';
|
||||
import 'package:fladder/util/themes_data.dart';
|
||||
import 'package:fladder/widgets/shared/back_intent_dpad.dart';
|
||||
|
||||
class VideoPlayer extends ConsumerStatefulWidget {
|
||||
const VideoPlayer({super.key});
|
||||
|
|
@ -83,38 +84,40 @@ class _VideoPlayerState extends ConsumerState<VideoPlayer> with WidgetsBindingOb
|
|||
},
|
||||
);
|
||||
|
||||
return Material(
|
||||
color: Colors.black,
|
||||
child: Theme(
|
||||
data: ThemesData.of(context).dark,
|
||||
child: Container(
|
||||
color: Colors.black,
|
||||
child: GestureDetector(
|
||||
onScaleUpdate: (details) {
|
||||
lastScale = details.scale;
|
||||
},
|
||||
onScaleEnd: (details) {
|
||||
if (lastScale < 1.0) {
|
||||
ref.read(videoPlayerSettingsProvider.notifier).setFillScreen(false, context: context);
|
||||
} else if (lastScale > 1.0) {
|
||||
ref.read(videoPlayerSettingsProvider.notifier).setFillScreen(true, context: context);
|
||||
}
|
||||
lastScale = 0.0;
|
||||
},
|
||||
child: VideoPlayerNextWrapper(
|
||||
video: Padding(
|
||||
padding: fillScreen ? EdgeInsets.zero : EdgeInsets.only(left: padding.left, right: padding.right),
|
||||
child: playerController.videoWidget(
|
||||
const Key("VideoPlayer"),
|
||||
fillScreen
|
||||
? (MediaQuery.of(context).orientation == Orientation.portrait ? videoFit : BoxFit.cover)
|
||||
: videoFit,
|
||||
return BackIntentDpad(
|
||||
child: Material(
|
||||
color: Colors.black,
|
||||
child: Theme(
|
||||
data: ThemesData.of(context).dark,
|
||||
child: Container(
|
||||
color: Colors.black,
|
||||
child: GestureDetector(
|
||||
onScaleUpdate: (details) {
|
||||
lastScale = details.scale;
|
||||
},
|
||||
onScaleEnd: (details) {
|
||||
if (lastScale < 1.0) {
|
||||
ref.read(videoPlayerSettingsProvider.notifier).setFillScreen(false, context: context);
|
||||
} else if (lastScale > 1.0) {
|
||||
ref.read(videoPlayerSettingsProvider.notifier).setFillScreen(true, context: context);
|
||||
}
|
||||
lastScale = 0.0;
|
||||
},
|
||||
child: VideoPlayerNextWrapper(
|
||||
video: Padding(
|
||||
padding: fillScreen ? EdgeInsets.zero : EdgeInsets.only(left: padding.left, right: padding.right),
|
||||
child: playerController.videoWidget(
|
||||
const Key("VideoPlayer"),
|
||||
fillScreen
|
||||
? (MediaQuery.of(context).orientation == Orientation.portrait ? videoFit : BoxFit.cover)
|
||||
: videoFit,
|
||||
),
|
||||
),
|
||||
controls: const DesktopControls(),
|
||||
overlays: [
|
||||
if (errorPlaying) const _VideoErrorWidget(),
|
||||
],
|
||||
),
|
||||
controls: const DesktopControls(),
|
||||
overlays: [
|
||||
if (errorPlaying) const _VideoErrorWidget(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ class DesktopControls extends ConsumerStatefulWidget {
|
|||
class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
||||
final GlobalKey _bottomControlsKey = GlobalKey();
|
||||
|
||||
late final initInputDevice = AdaptiveLayout.inputDeviceOf(context);
|
||||
|
||||
late RestartableTimer timer = RestartableTimer(
|
||||
const Duration(seconds: 5),
|
||||
() => mounted ? toggleOverlay(value: false) : null,
|
||||
|
|
@ -95,12 +97,9 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
children: [
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
onTap: AdaptiveLayout.inputDeviceOf(context) == InputDevice.pointer
|
||||
? () => player.playOrPause()
|
||||
: () => toggleOverlay(),
|
||||
onDoubleTap: AdaptiveLayout.inputDeviceOf(context) == InputDevice.pointer
|
||||
? () => fullScreenHelper.toggleFullScreen(ref)
|
||||
: null,
|
||||
onTap: initInputDevice == InputDevice.pointer ? () => player.playOrPause() : () => toggleOverlay(),
|
||||
onDoubleTap:
|
||||
initInputDevice == InputDevice.pointer ? () => fullScreenHelper.toggleFullScreen(ref) : null,
|
||||
),
|
||||
),
|
||||
if (subtitleWidget != null) subtitleWidget,
|
||||
|
|
@ -245,7 +244,7 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (AdaptiveLayout.inputDeviceOf(context) == InputDevice.touch)
|
||||
if (initInputDevice == InputDevice.touch)
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Tooltip(
|
||||
|
|
@ -362,7 +361,7 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (AdaptiveLayout.isDesktop(context))
|
||||
if (initInputDevice == InputDevice.pointer)
|
||||
Tooltip(
|
||||
message: context.localized.stop,
|
||||
child: IconButton(
|
||||
|
|
@ -379,7 +378,7 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
),
|
||||
),
|
||||
},
|
||||
if (AdaptiveLayout.isDesktop(context) &&
|
||||
if (initInputDevice == InputDevice.pointer &&
|
||||
AdaptiveLayout.viewSizeOf(context) > ViewSize.phone) ...[
|
||||
VideoVolumeSlider(
|
||||
onChanged: () => resetTimer(),
|
||||
|
|
@ -651,7 +650,7 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
|
||||
Future<void> clearOverlaySettings() async {
|
||||
toggleOverlay(value: true);
|
||||
if (AdaptiveLayout.inputDeviceOf(context) != InputDevice.pointer) {
|
||||
if (initInputDevice != InputDevice.pointer) {
|
||||
ScreenBrightness().resetApplicationScreenBrightness();
|
||||
} else {
|
||||
disableFullScreen();
|
||||
|
|
@ -717,7 +716,7 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
return true;
|
||||
case VideoHotKeys.exit:
|
||||
disableFullScreen();
|
||||
return true;
|
||||
return false;
|
||||
case VideoHotKeys.mute:
|
||||
if (volume != 0) {
|
||||
previousVolume = volume;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue