Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

chore: disable more player animations on linux

Predidit79200ec83ae9
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dart
index beb3311b..0670ca50 100644
--- a/lib/pages/player/player_item.dart
+++ b/lib/pages/player/player_item.dart
@@ -40,6 +40,7 @@ class PlayerItem extends StatefulWidget {
required this.onBackPressed,
required this.keyboardFocus,
required this.sendDanmaku,
+ this.disableAnimations = false,
});
final VoidCallback openMenu;
@@ -49,6 +50,7 @@ class PlayerItem extends StatefulWidget {
final void Function(BuildContext) onBackPressed;
final void Function(String) sendDanmaku;
final FocusNode keyboardFocus;
+ final bool disableAnimations;
@override
State<PlayerItem> createState() => _PlayerItemState();
@@ -1303,11 +1305,8 @@ class _PlayerItemState extends State<PlayerItem>
showSyncPlayRoomCreateDialog:
showSyncPlayRoomCreateDialog,
showSyncPlayEndPointSwitchDialog:
- showSyncPlayEndPointSwitchDialog,
- // disable animation on linux to avoid fucked-up gtk shared openGL context issue.
- // damn gtk can't even handle opengl context on other thread correctly.
- // we can only disable animation to avoid falling into the gtk/flutter/mpv openGL context interoper hell.
- disableAnimations: Platform.isLinux,
+ showSyncPlayEndPointSwitchDialog,
+ disableAnimations: widget.disableAnimations,
)
: SmallestPlayerItemPanel(
onBackPressed: widget.onBackPressed,
@@ -1329,7 +1328,7 @@ class _PlayerItemState extends State<PlayerItem>
showSyncPlayRoomCreateDialog,
showSyncPlayEndPointSwitchDialog:
showSyncPlayEndPointSwitchDialog,
- disableAnimations: Platform.isLinux,
+ disableAnimations: widget.disableAnimations,
),
// 播放器手势控制
Positioned.fill(
diff --git a/lib/pages/video/video_page.dart b/lib/pages/video/video_page.dart
index 6a3e19f1..81998f69 100644
--- a/lib/pages/video/video_page.dart
+++ b/lib/pages/video/video_page.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:io';
import 'package:canvas_danmaku/models/danmaku_content_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
@@ -67,6 +68,11 @@ class _VideoPageState extends State<VideoPage>
// The first parameter is the video source URL and the second parameter is the video offset (start position)
late final StreamSubscription<(String, int)> _videoURLSubscription;
+ // disable animation on linux to avoid fucked-up gtk shared openGL context issue.
+ // damn gtk can't even handle opengl context on other thread correctly.
+ // we can only disable animation to avoid falling into the gtk/flutter/mpv openGL context interoper hell.
+ final bool disableAnimations = Platform.isLinux;
+
@override
void initState() {
super.initState();
@@ -247,16 +253,22 @@ class _VideoPageState extends State<VideoPage>
void openTabBodyAnimated() {
if (videoPageController.showTabBody) {
- animation.forward();
+ if (!disableAnimations) {
+ animation.forward();
+ }
menuJumpToCurrentEpisode();
}
}
void closeTabBodyAnimated() {
- animation.reverse();
- Future.delayed(const Duration(milliseconds: 120), () {
+ if (!disableAnimations) {
+ animation.reverse();
+ Future.delayed(const Duration(milliseconds: 120), () {
+ videoPageController.showTabBody = false;
+ });
+ } else {
videoPageController.showTabBody = false;
- });
+ }
keyboardFocus.requestFocus();
}
@@ -429,54 +441,21 @@ class _VideoPageState extends State<VideoPage>
],
),
- // when is wideScreen, show tabBody on the right side with SlideTransition
+ // when is wideScreen, show tabBody on the right side with SlideTransition or direct visibility
if (isWideScreen && videoPageController.showTabBody) ...[
- FadeTransition(
- opacity: _maskOpacityAnimation,
- child: GestureDetector(
- onTap: closeTabBodyAnimated,
- child: Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.centerLeft,
- end: Alignment.centerRight,
- colors: [
- Colors.black.withValues(alpha: 0.5),
- Colors.transparent,
- ],
- ),
- ),
- width: double.infinity,
- height: double.infinity,
- ),
+ if (disableAnimations) ...[
+ sideTabMask,
+ sideTabBody,
+ ] else ...[
+ FadeTransition(
+ opacity: _maskOpacityAnimation,
+ child: sideTabMask,
),
- ),
- SlideTransition(
- position: _rightOffsetAnimation,
- child: SizedBox(
- height: MediaQuery.sizeOf(context).height,
- // 420 is chosen based on 426.6(1/3 of 1280)
- width: (!Utils.isDesktop() && !Utils.isTablet())
- ? MediaQuery.sizeOf(context).height
- : (MediaQuery.sizeOf(context).width / 3 > 420
- ? 420
- : MediaQuery.sizeOf(context).width / 3),
- child: Container(
- color: Theme.of(context).canvasColor,
- child: GridViewObserver(
- controller: observerController,
- child: (Utils.isDesktop() || Utils.isTablet())
- ? tabBody
- : Column(
- children: [
- menuBar,
- menuBody,
- ],
- ),
- ),
- ),
+ SlideTransition(
+ position: _rightOffsetAnimation,
+ child: sideTabBody,
),
- ),
+ ],
],
],
)),
@@ -486,6 +465,51 @@ class _VideoPageState extends State<VideoPage>
);
}
+ Widget get sideTabBody {
+ return SizedBox(
+ height: MediaQuery.sizeOf(context).height,
+ width: (!Utils.isDesktop() && !Utils.isTablet())
+ ? MediaQuery.sizeOf(context).height
+ : (MediaQuery.sizeOf(context).width / 3 > 420
+ ? 420
+ : MediaQuery.sizeOf(context).width / 3),
+ child: Container(
+ color: Theme.of(context).canvasColor,
+ child: GridViewObserver(
+ controller: observerController,
+ child: (Utils.isDesktop() || Utils.isTablet())
+ ? tabBody
+ : Column(
+ children: [
+ menuBar,
+ menuBody,
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget get sideTabMask {
+ return GestureDetector(
+ onTap: closeTabBodyAnimated,
+ child: Container(
+ decoration: BoxDecoration(
+ gradient: LinearGradient(
+ begin: Alignment.centerLeft,
+ end: Alignment.centerRight,
+ colors: [
+ Colors.black.withValues(alpha: 0.5),
+ Colors.transparent,
+ ],
+ ),
+ ),
+ width: double.infinity,
+ height: double.infinity,
+ ),
+ );
+ }
+
Widget get playerBody {
return Stack(
children: [
@@ -641,6 +665,7 @@ class _VideoPageState extends State<VideoPage>
onBackPressed: onBackPressed,
keyboardFocus: keyboardFocus,
sendDanmaku: sendDanmaku,
+ disableAnimations: disableAnimations,
),
),
diff --git a/pubspec.lock b/pubspec.lock
index d214c25d..e0a2b9d6 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1782,4 +1782,4 @@ packages:
version: "3.1.3"
sdks:
dart: ">=3.8.0 <4.0.0"
- flutter: ">=3.35.5"
+ flutter: ">=3.35.6"