Skip to content

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

fix player panel animation for mobile

Prediditb2952aac5efd
diff --git a/lib/pages/player/player_controller.dart b/lib/pages/player/player_controller.dart
index 24a4c25b..175af1da 100644
--- a/lib/pages/player/player_controller.dart
+++ b/lib/pages/player/player_controller.dart
@@ -1,7 +1,6 @@
import 'dart:io';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:media_kit/media_kit.dart';
-import 'package:flutter/material.dart';
import 'package:media_kit_video/media_kit_video.dart';
import 'package:kazumi/modules/danmaku/danmaku_module.dart';
import 'package:mobx/mobx.dart';
@@ -47,7 +46,7 @@ abstract class _PlayerController with Store {
@observable
bool lockPanel = false;
@observable
- bool showVideoController = false;
+ bool showVideoController = true;
@observable
bool showSeekTime = false;
@observable
@@ -61,12 +60,6 @@ abstract class _PlayerController with Store {
@observable
bool volumeSeeking = false;
- // 过渡动画
- AnimationController? animationController;
- late Animation<Offset> bottomOffsetAnimation;
- late Animation<Offset> topOffsetAnimation;
- late Animation<Offset> leftOffsetAnimation;
-
// 视频地址
String videoUrl = '';
// DanDanPlay 弹幕ID
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dart
index 0c94067d..28b25d80 100644
--- a/lib/pages/player/player_item.dart
+++ b/lib/pages/player/player_item.dart
@@ -95,6 +95,9 @@ class _PlayerItemState extends State<PlayerItem>
Timer? mouseScrollerTimer;
Timer? hideVolumeUITimer;
+ // 过渡动画控制器
+ AnimationController? animationController;
+
double lastPlayerSpeed = 1.0;
int episodeNum = 0;
@@ -223,14 +226,14 @@ class _PlayerItemState extends State<PlayerItem>
}
void displayVideoController() {
- playerController.animationController?.forward();
+ animationController?.forward();
hideTimer?.cancel();
startHideTimer();
playerController.showVideoController = true;
}
void hideVideoController() {
- playerController.animationController?.reverse();
+ animationController?.reverse();
hideTimer?.cancel();
playerController.showVideoController = false;
}
@@ -282,7 +285,7 @@ class _PlayerItemState extends State<PlayerItem>
hideTimer = Timer(const Duration(seconds: 4), () {
if (mounted) {
playerController.showVideoController = false;
- playerController.animationController?.reverse();
+ animationController?.reverse();
}
hideTimer = null;
});
@@ -521,31 +524,10 @@ class _PlayerItemState extends State<PlayerItem>
category: AudioSessionCategory.playback);
}
WidgetsBinding.instance.addObserver(this);
- playerController.animationController = AnimationController(
+ animationController ??= AnimationController(
duration: const Duration(milliseconds: 300),
vsync: this,
);
- playerController.topOffsetAnimation = Tween<Offset>(
- begin: const Offset(0.0, -1.0),
- end: const Offset(0.0, 0.0),
- ).animate(CurvedAnimation(
- parent: playerController.animationController!,
- curve: Curves.easeInOut,
- ));
- playerController.bottomOffsetAnimation = Tween<Offset>(
- begin: const Offset(0.0, 1.0),
- end: const Offset(0.0, 0.0),
- ).animate(CurvedAnimation(
- parent: playerController.animationController!,
- curve: Curves.easeInOut,
- ));
- playerController.leftOffsetAnimation = Tween<Offset>(
- begin: const Offset(1.0, 0.0),
- end: const Offset(0.0, 0.0),
- ).animate(CurvedAnimation(
- parent: playerController.animationController!,
- curve: Curves.easeInOut,
- ));
webDavEnable = setting.get(SettingBoxKey.webDavEnable, defaultValue: false);
playerController.danmakuOn =
setting.get(SettingBoxKey.danmakuEnabledByDefault, defaultValue: false);
@@ -584,11 +566,14 @@ class _PlayerItemState extends State<PlayerItem>
WidgetsBinding.instance.removeObserver(this);
windowManager.removeListener(this);
playerTimer?.cancel();
- playerController.animationController?.dispose();
- playerController.animationController = null;
+ hideTimer?.cancel();
+ mouseScrollerTimer?.cancel();
+ hideVolumeUITimer?.cancel();
+ animationController?.dispose();
+ animationController = null;
// Reset player panel state
playerController.lockPanel = false;
- playerController.showVideoController = false;
+ playerController.showVideoController = true;
playerController.showSeekTime = false;
playerController.showBrightness = false;
playerController.showVolume = false;
@@ -832,6 +817,7 @@ class _PlayerItemState extends State<PlayerItem>
handleFullscreen: handleFullscreen,
handleProgressBarDragStart: handleProgressBarDragStart,
handleProgressBarDragEnd: handleProgressBarDragEnd,
+ animationController: animationController!,
),
// 播放器手势控制
Positioned.fill(
diff --git a/lib/pages/player/player_item_panel.dart b/lib/pages/player/player_item_panel.dart
index 8fde0218..e15be8db 100644
--- a/lib/pages/player/player_item_panel.dart
+++ b/lib/pages/player/player_item_panel.dart
@@ -28,6 +28,7 @@ class PlayerItemPanel extends StatefulWidget {
required this.handleFullscreen,
required this.handleProgressBarDragStart,
required this.handleProgressBarDragEnd,
+ required this.animationController,
required this.openMenu,
});
@@ -39,6 +40,7 @@ class PlayerItemPanel extends StatefulWidget {
final void Function() handleFullscreen;
final void Function(ThumbDragDetails details) handleProgressBarDragStart;
final void Function() handleProgressBarDragEnd;
+ final AnimationController animationController;
@override
State<PlayerItemPanel> createState() => _PlayerItemPanelState();
@@ -47,6 +49,9 @@ class PlayerItemPanel extends StatefulWidget {
class _PlayerItemPanelState extends State<PlayerItemPanel> {
Box setting = GStorage.setting;
late bool haEnable;
+ late Animation<Offset> topOffsetAnimation;
+ late Animation<Offset> bottomOffsetAnimation;
+ late Animation<Offset> leftOffsetAnimation;
final VideoPageController videoPageController =
Modular.get<VideoPageController>();
final InfoController infoController = Modular.get<InfoController>();
@@ -265,6 +270,27 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
@override
void initState() {
super.initState();
+ topOffsetAnimation = Tween<Offset>(
+ begin: const Offset(0.0, -1.0),
+ end: const Offset(0.0, 0.0),
+ ).animate(CurvedAnimation(
+ parent: widget.animationController,
+ curve: Curves.easeInOut,
+ ));
+ bottomOffsetAnimation = Tween<Offset>(
+ begin: const Offset(0.0, 1.0),
+ end: const Offset(0.0, 0.0),
+ ).animate(CurvedAnimation(
+ parent: widget.animationController,
+ curve: Curves.easeInOut,
+ ));
+ leftOffsetAnimation = Tween<Offset>(
+ begin: const Offset(1.0, 0.0),
+ end: const Offset(0.0, 0.0),
+ ).animate(CurvedAnimation(
+ parent: widget.animationController,
+ curve: Curves.easeInOut,
+ ));
haEnable = setting.get(SettingBoxKey.hAenable, defaultValue: true);
}
@@ -303,7 +329,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
child: Visibility(
visible: !playerController.lockPanel,
child: SlideTransition(
- position: playerController.topOffsetAnimation,
+ position: topOffsetAnimation,
child: Container(
height: 50,
decoration: BoxDecoration(
@@ -330,7 +356,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
child: Visibility(
visible: !playerController.lockPanel,
child: SlideTransition(
- position: playerController.bottomOffsetAnimation,
+ position: bottomOffsetAnimation,
child: Container(
height: 50,
decoration: BoxDecoration(
@@ -466,7 +492,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
top: 0,
bottom: 0,
child: SlideTransition(
- position: playerController.leftOffsetAnimation,
+ position: leftOffsetAnimation,
child: Column(children: [
const Spacer(),
(playerController.lockPanel)
@@ -504,7 +530,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
child: Visibility(
visible: !playerController.lockPanel,
child: SlideTransition(
- position: playerController.topOffsetAnimation,
+ position: topOffsetAnimation,
child: Row(
children: [
IconButton(
@@ -668,7 +694,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
child: Visibility(
visible: !playerController.lockPanel,
child: SlideTransition(
- position: playerController.bottomOffsetAnimation,
+ position: bottomOffsetAnimation,
child: Row(
children: [
IconButton(