forked from Nexus/nexus
parent
5df7c2c00a
commit
b63fcc30b7
1 changed files with 38 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
import "dart:async";
|
import "dart:async";
|
||||||
|
import "dart:io";
|
||||||
|
|
||||||
import "package:better_player/better_player.dart";
|
import "package:better_player/better_player.dart";
|
||||||
|
import "package:flutter/services.dart";
|
||||||
import "package:material_ui/material_ui.dart";
|
import "package:material_ui/material_ui.dart";
|
||||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||||
import "package:nexus/controllers/client.dart";
|
import "package:nexus/controllers/client.dart";
|
||||||
|
|
@ -10,6 +12,7 @@ import "package:nexus/models/info/video.dart";
|
||||||
import "package:nexus/widgets/common/error_dialog.dart";
|
import "package:nexus/widgets/common/error_dialog.dart";
|
||||||
import "package:flutter_hooks/flutter_hooks.dart";
|
import "package:flutter_hooks/flutter_hooks.dart";
|
||||||
import "package:nexus/widgets/players/player_controls.dart";
|
import "package:nexus/widgets/players/player_controls.dart";
|
||||||
|
import "package:window_manager/window_manager.dart";
|
||||||
|
|
||||||
class const VideoPlayer(
|
class const VideoPlayer(
|
||||||
final Uri uri,
|
final Uri uri,
|
||||||
|
|
@ -32,6 +35,41 @@ class const VideoPlayer(
|
||||||
PlayerConfiguration(
|
PlayerConfiguration(
|
||||||
aspectRatio: aspectRatio,
|
aspectRatio: aspectRatio,
|
||||||
fit: .contain,
|
fit: .contain,
|
||||||
|
autoDetectFullscreenDeviceOrientation: true,
|
||||||
|
routePageBuilder:
|
||||||
|
(context, animation, secondaryAnimation, provider) => HookBuilder(
|
||||||
|
builder: (context) {
|
||||||
|
useEffect(() {
|
||||||
|
if (!(Platform.isLinux ||
|
||||||
|
Platform.isMacOS ||
|
||||||
|
Platform.isWindows)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final window = WindowManager.instance.getCurrent();
|
||||||
|
if (window == null || window.isFullScreen) return null;
|
||||||
|
|
||||||
|
window.isFullScreen = true;
|
||||||
|
return () => window.isFullScreen = false;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return Focus(
|
||||||
|
autofocus: true,
|
||||||
|
onKeyEvent: (_, event) {
|
||||||
|
if (event is KeyDownEvent &&
|
||||||
|
event.logicalKey == .escape) {
|
||||||
|
provider.controller.exitFullScreen();
|
||||||
|
return .handled;
|
||||||
|
}
|
||||||
|
return .ignored;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
|
body: SizedBox.expand(child: provider),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
controlsConfiguration: PlayerControlsConfiguration(
|
controlsConfiguration: PlayerControlsConfiguration(
|
||||||
playerTheme: .custom,
|
playerTheme: .custom,
|
||||||
customControlsBuilder: (controller, _) => HookBuilder(
|
customControlsBuilder: (controller, _) => HookBuilder(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue