diff --git a/lib/modules/live_play/widgets/video_player/video_controller.dart b/lib/modules/live_play/widgets/video_player/video_controller.dart index 4ec5d6b8..12f23957 100644 --- a/lib/modules/live_play/widgets/video_player/video_controller.dart +++ b/lib/modules/live_play/widgets/video_player/video_controller.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:developer'; import 'dart:io'; @@ -27,7 +28,6 @@ class VideoController with ChangeNotifier { final bool autoPlay; final videoFit = BoxFit.contain.obs; - ScreenBrightness brightnessController = ScreenBrightness(); final hasError = false.obs; @@ -39,19 +39,18 @@ class VideoController with ChangeNotifier { bool get supportPip => Platform.isAndroid; bool get supportWindowFull => Platform.isWindows || Platform.isLinux; bool get fullscreenUI => isFullscreen.value || isWindowFullscreen.value; - // Video player status + // Video player status // A [GlobalKey] is required to access the programmatic fullscreen interface. late final GlobalKey key = GlobalKey(); // Create a [Player] to control playback. late final player = Player(); // Create a [VideoController] to handle video output from [Player]. - String? vo = Platform.isAndroid ? 'gpu' : 'libmpv'; - String? hwdec = Platform.isAndroid ? 'mediacodec' : 'auto'; - late final controller = media_kit_video.VideoController(player, configuration: media_kit_video.VideoControllerConfiguration( - enableHardwareAcceleration: false, - hwdec: hwdec - )); + String? vo = Platform.isAndroid ? 'mediacodec_embed' : 'libmpv'; + String? hwdec = Platform.isAndroid ? 'mediacodec' : 'auto'; + late final controller = media_kit_video.VideoController(player, + configuration: media_kit_video.VideoControllerConfiguration( + enableHardwareAcceleration: true, vo: vo, hwdec: hwdec)); // Controller ui status Timer? showControllerTimer; final showController = true.obs; @@ -114,17 +113,20 @@ class VideoController with ChangeNotifier { void initVideoController() { FlutterVolumeController.showSystemUI = false; setDataSource(datasource); - player.stream.playing.listen((bool playing) { + controller.player.stream.playing.listen((bool playing) { if (playing) { isPlaying.value = true; } else { isPlaying.value = false; } }); - // fix auto fullscreen - if (fullScreenByDefault && datasource.isNotEmpty) { - Timer(const Duration(milliseconds: 500), () => toggleFullScreen()); - } + controller.player.stream.error.listen((String err) { + log(err); + }); + // fix auto fullscreen + if (fullScreenByDefault && datasource.isNotEmpty) { + Timer(const Duration(milliseconds: 500), () => toggleFullScreen()); + } } // Danmaku player control @@ -210,10 +212,10 @@ class VideoController with ChangeNotifier { player.playOrPause(); } - void toggleFullScreen() { + void toggleFullScreen() { // disable locked showLocked.value = false; - // fix danmaku overlap bug + // fix danmaku overlap bug if (!hideDanmaku.value) { hideDanmaku.value = true; Timer(const Duration(milliseconds: 500), () { @@ -262,11 +264,13 @@ class VideoController with ChangeNotifier { enableController(); } - void enterPipMode(BuildContext context) async {} + void enterPipMode(BuildContext context) async { + + } // volumn & brightness Future volumn() async { - return await FlutterVolumeController.getVolume(); + return await FlutterVolumeController.getVolume(); } Future brightness() async { @@ -359,10 +363,10 @@ class DesktopFullscreen extends StatelessWidget { body: Stack( children: [ media_kit_video.Video( - controller: controller.controller, - fit: controller.videoFit.value, - controls: (state) => VideoControllerPanel(controller: controller), - ) + controller: controller.controller, + fit: controller.videoFit.value, + controls: (state) => VideoControllerPanel(controller: controller), + ) ], ), ); diff --git a/lib/modules/live_play/widgets/video_player/video_controller_panel.dart b/lib/modules/live_play/widgets/video_player/video_controller_panel.dart index e581b36a..23155210 100644 --- a/lib/modules/live_play/widgets/video_player/video_controller_panel.dart +++ b/lib/modules/live_play/widgets/video_player/video_controller_panel.dart @@ -171,8 +171,8 @@ class TopActionBar extends StatelessWidget { const DatetimeInfo(), BatteryInfo(controller: controller), ], - if (!controller.fullscreenUI && controller.supportPip) - PIPButton(controller: controller), + // if (!controller.fullscreenUI && controller.supportPip) + // PIPButton(controller: controller), ]), ), ), @@ -346,6 +346,7 @@ class DanmakuViewer extends StatelessWidget { controller: controller.danmakuController, speed: controller.danmakuSpeed.value.toInt(), maxBulletHeight: controller.danmakuFontSize * 1.5, + safeBottomHeight: 50, massiveMode: false, // disabled by default child: Container(), ), diff --git a/pubspec.lock b/pubspec.lock index 8ac3258a..1249ba74 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -259,10 +259,10 @@ packages: dependency: "direct main" description: name: flutter_barrage - sha256: cc79a9bb08bcfd76e9856337c168f4b19e16916ca7bb6d929cc6f02663d3387c + sha256: d47404608dc66d4a08a5224179cfb4405aefe524f915d03dee4f5fab0cca3094 url: "https://pub.flutter-io.cn" source: hosted - version: "0.5.5" + version: "0.5.4" flutter_blurhash: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index c824fbd6..e3766b44 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,7 +49,7 @@ dependencies: flutter_staggered_grid_view: ^0.7.0 # barrage wall - flutter_barrage: ^0.5.4 + flutter_barrage: 0.5.4 flutter_exit_app: ^1.1.2 # database