Skip to content

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

add player panel transition

Predidit561cb7730514
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dart
index 2c18dd6f..fa40ed6c 100644
--- a/lib/pages/player/player_item.dart
+++ b/lib/pages/player/player_item.dart
@@ -35,7 +35,10 @@ class PlayerItem extends StatefulWidget {
}
class _PlayerItemState extends State<PlayerItem>
- with WindowListener, WidgetsBindingObserver {
+ with
+ WindowListener,
+ WidgetsBindingObserver,
+ SingleTickerProviderStateMixin {
Box setting = GStorage.setting;
final PlayerController playerController = Modular.get<PlayerController>();
final VideoPageController videoPageController =
@@ -70,6 +73,11 @@ class _PlayerItemState extends State<PlayerItem>
late bool _massiveMode;
late bool _danmakuColor;
+ // 过渡动画
+ late AnimationController _animationController;
+ late Animation<Offset> _bottomOffsetAnimation;
+ late Animation<Offset> _topOffsetAnimation;
+
Timer? hideTimer;
Timer? playerTimer;
Timer? mouseScrollerTimer;
@@ -85,6 +93,35 @@ class _PlayerItemState extends State<PlayerItem>
}
void _handleTap() {
+ if (!showPositioned) {
+ _animationController.forward();
+ if (hideTimer != null) {
+ hideTimer!.cancel();
+ }
+ hideTimer = Timer(const Duration(seconds: 4), () {
+ if (mounted) {
+ setState(() {
+ showPositioned = false;
+ });
+ _animationController.reverse();
+ }
+ hideTimer = null;
+ });
+ } else {
+ _animationController.reverse();
+ if (hideTimer != null) {
+ hideTimer!.cancel();
+ }
+ }
+ setState(() {
+ showPositioned = !showPositioned;
+ });
+ }
+
+ void _handleHove() {
+ if (!showPositioned) {
+ _animationController.forward();
+ }
setState(() {
showPositioned = true;
});
@@ -97,6 +134,7 @@ class _PlayerItemState extends State<PlayerItem>
setState(() {
showPositioned = false;
});
+ _animationController.reverse();
}
hideTimer = null;
});
@@ -399,6 +437,24 @@ class _PlayerItemState extends State<PlayerItem>
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
+ _animationController = AnimationController(
+ duration: const Duration(milliseconds: 300),
+ vsync: this,
+ );
+ _topOffsetAnimation = Tween<Offset>(
+ begin: const Offset(0.0, -1.0),
+ end: const Offset(0.0, 0.0),
+ ).animate(CurvedAnimation(
+ parent: _animationController,
+ curve: Curves.easeInOut,
+ ));
+ _bottomOffsetAnimation = Tween<Offset>(
+ begin: const Offset(0.0, 1.0),
+ end: const Offset(0.0, 0.0),
+ ).animate(CurvedAnimation(
+ parent: _animationController,
+ curve: Curves.easeInOut,
+ ));
webDavEnable = setting.get(SettingBoxKey.webDavEnable, defaultValue: false);
playerController.danmakuOn =
setting.get(SettingBoxKey.danmakuEnabledByDefault, defaultValue: false);
@@ -416,6 +472,7 @@ class _PlayerItemState extends State<PlayerItem>
setting.get(SettingBoxKey.danmakuMassive, defaultValue: false);
_danmakuColor = setting.get(SettingBoxKey.danmakuColor, defaultValue: true);
playerTimer = getPlayerTimer();
+ _handleTap();
}
@override
@@ -424,6 +481,7 @@ class _PlayerItemState extends State<PlayerItem>
if (playerTimer != null) {
playerTimer!.cancel();
}
+ _animationController.dispose();
super.dispose();
}
@@ -440,62 +498,80 @@ class _PlayerItemState extends State<PlayerItem>
child: SafeArea(
child: Scaffold(
body: Observer(builder: (context) {
- return Column(
- children: [
- Container(
- color: Colors.black,
- child: MouseRegion(
- cursor: (videoPageController.androidFullscreen &&
- !showPositioned)
- ? SystemMouseCursors.none
- : SystemMouseCursors.basic,
- onHover: (_) {
- _handleTap();
- },
- child: FocusTraversalGroup(
- child: FocusScope(
- node: FocusScopeNode(),
- child: Listener(
- onPointerSignal: (pointerSignal) {
- if (pointerSignal is PointerScrollEvent) {
- _handleMouseScroller();
- final scrollDelta = pointerSignal.scrollDelta;
- // debugPrint('滚轮滑动距离: ${scrollDelta.dy}');
- final double volume = playerController.volume -
- scrollDelta.dy / 6000;
- final double result = volume.clamp(0.0, 1.0);
- setVolume(result);
- playerController.volume = result;
- }
- },
- child: KeyboardListener(
- autofocus: true,
- focusNode: _focusNode,
- onKeyEvent: (KeyEvent event) {
- if (event is KeyDownEvent) {
- // 当空格键被按下时
- _handleTap();
- if (event.logicalKey ==
- LogicalKeyboardKey.space) {
- // debugPrint('空格键被按下');
- try {
- playerController.playOrPause();
- } catch (e) {
- KazumiLogger()
- .log(Level.error, e.toString());
+ return ClipRect(
+ child: Container(
+ color: Colors.black,
+ child: MouseRegion(
+ cursor:
+ (videoPageController.androidFullscreen && !showPositioned)
+ ? SystemMouseCursors.none
+ : SystemMouseCursors.basic,
+ onHover: (_) {
+ _handleHove();
+ },
+ child: FocusTraversalGroup(
+ child: FocusScope(
+ node: FocusScopeNode(),
+ child: Listener(
+ onPointerSignal: (pointerSignal) {
+ if (pointerSignal is PointerScrollEvent) {
+ _handleMouseScroller();
+ final scrollDelta = pointerSignal.scrollDelta;
+ // debugPrint('滚轮滑动距离: ${scrollDelta.dy}');
+ final double volume =
+ playerController.volume - scrollDelta.dy / 6000;
+ final double result = volume.clamp(0.0, 1.0);
+ setVolume(result);
+ playerController.volume = result;
+ }
+ },
+ child: KeyboardListener(
+ autofocus: true,
+ focusNode: _focusNode,
+ onKeyEvent: (KeyEvent event) {
+ if (event is KeyDownEvent) {
+ // 当空格键被按下时
+ _handleTap();
+ if (event.logicalKey ==
+ LogicalKeyboardKey.space) {
+ // debugPrint('空格键被按下');
+ try {
+ playerController.playOrPause();
+ } catch (e) {
+ KazumiLogger().log(Level.error, e.toString());
+ }
+ }
+ // 右方向键被按下
+ if (event.logicalKey ==
+ LogicalKeyboardKey.arrowRight) {
+ // debugPrint('右方向键被按下');
+ try {
+ if (playerTimer != null) {
+ playerTimer!.cancel();
}
+ playerController.currentPosition = Duration(
+ seconds: playerController
+ .currentPosition.inSeconds +
+ 10);
+ playerController
+ .seek(playerController.currentPosition);
+ playerTimer = getPlayerTimer();
+ } catch (e) {
+ KazumiLogger().log(Level.error, e.toString());
}
- // 右方向键被按下
- if (event.logicalKey ==
- LogicalKeyboardKey.arrowRight) {
- // debugPrint('右方向键被按下');
+ }
+ // 左方向键被按下
+ if (event.logicalKey ==
+ LogicalKeyboardKey.arrowLeft) {
+ if (playerController.currentPosition.inSeconds >
+ 10) {
try {
if (playerTimer != null) {
playerTimer!.cancel();
}
playerController.currentPosition = Duration(
seconds: playerController
- .currentPosition.inSeconds +
+ .currentPosition.inSeconds -
10);
playerController
.seek(playerController.currentPosition);
@@ -505,231 +581,266 @@ class _PlayerItemState extends State<PlayerItem>
.log(Level.error, e.toString());
}
}
- // 左方向键被按下
- if (event.logicalKey ==
- LogicalKeyboardKey.arrowLeft) {
- if (playerController
- .currentPosition.inSeconds >
- 10) {
- try {
- if (playerTimer != null) {
- playerTimer!.cancel();
- }
- playerController.currentPosition =
- Duration(
- seconds: playerController
- .currentPosition
- .inSeconds -
- 10);
- playerController.seek(
- playerController.currentPosition);
- playerTimer = getPlayerTimer();
- } catch (e) {
- KazumiLogger()
- .log(Level.error, e.toString());
- }
- }
- }
- // Esc键被按下
- if (event.logicalKey ==
- LogicalKeyboardKey.escape) {
- if (videoPageController.androidFullscreen) {
- try {
- danmakuController.onClear();
- } catch (_) {}
- videoPageController.exitFullScreen();
- videoPageController.androidFullscreen =
- !videoPageController.androidFullscreen;
- } else {
- windowManager.hide();
- }
- }
- // F键被按下
- if (event.logicalKey ==
- LogicalKeyboardKey.keyF) {
- _handleFullscreen();
- }
- // D键盘被按下
- if (event.logicalKey ==
- LogicalKeyboardKey.keyD) {
- _handleDanmaku();
+ }
+ // Esc键被按下
+ if (event.logicalKey ==
+ LogicalKeyboardKey.escape) {
+ if (videoPageController.androidFullscreen) {
+ try {
+ danmakuController.onClear();
+ } catch (_) {}
+ videoPageController.exitFullScreen();
+ videoPageController.androidFullscreen =
+ !videoPageController.androidFullscreen;
+ } else {
+ windowManager.hide();
}
}
- },
- child: SizedBox(
- height: videoPageController.androidFullscreen
- ? (MediaQuery.of(context).size.height)
- : (MediaQuery.of(context).size.width *
- 9.0 /
- (16.0)),
- width: MediaQuery.of(context).size.width,
- child:
- Stack(alignment: Alignment.center, children: [
- Center(child: playerSurface),
- (playerController.isBuffering ||
- videoPageController.loading)
- ? const Positioned.fill(
- child: Center(
- child: CircularProgressIndicator(),
- ),
- )
- : Container(),
- GestureDetector(
- onTap: () async {
- _handleTap();
- try {
- playerController.volume =
- await FlutterVolumeController
- .getVolume() ??
- playerController.volume;
- } catch (e) {
- KazumiLogger()
- .log(Level.error, e.toString());
- }
- },
- onDoubleTap: () {
+ // F键被按下
+ if (event.logicalKey == LogicalKeyboardKey.keyF) {
+ _handleFullscreen();
+ }
+ // D键盘被按下
+ if (event.logicalKey == LogicalKeyboardKey.keyD) {
+ _handleDanmaku();
+ }
+ }
+ },
+ child: SizedBox(
+ height: videoPageController.androidFullscreen
+ ? (MediaQuery.of(context).size.height)
+ : (MediaQuery.of(context).size.width *
+ 9.0 /
+ (16.0)),
+ width: MediaQuery.of(context).size.width,
+ child:
+ Stack(alignment: Alignment.center, children: [
+ Center(child: playerSurface),
+ (playerController.isBuffering ||
+ videoPageController.loading)
+ ? const Positioned.fill(
+ child: Center(
+ child: CircularProgressIndicator(),
+ ),
+ )
+ : Container(),
+ GestureDetector(
+ onTap: () async {
+ _handleTap();
+ try {
+ playerController.volume =
+ await FlutterVolumeController
+ .getVolume() ??
+ playerController.volume;
+ } catch (e) {
+ KazumiLogger()
+ .log(Level.error, e.toString());
+ }
+ },
+ onDoubleTap: () {
+ if (!showPositioned) {
_handleTap();
- if (playerController.playing) {
- playerController.pause();
- } else {
- playerController.play();
- }
- },
- onLongPressStart: (_) {
- setState(() {
- showPlaySpeed = true;
- });
- playerController.setPlaybackSpeed(
- playerController.playerSpeed * 2.5);
- },
- onLongPressEnd: (_) {
- setState(() {
- showPlaySpeed = false;
- });
- playerController.setPlaybackSpeed(
- playerController.playerSpeed / 2.5);
- },
- child: Container(
- color: Colors.transparent,
- width: double.infinity,
- height: double.infinity,
- ),
+ }
+ if (playerController.playing) {
+ playerController.pause();
+ } else {
+ playerController.play();
+ }
+ },
+ onLongPressStart: (_) {
+ setState(() {
+ showPlaySpeed = true;
+ });
+ playerController.setPlaybackSpeed(
+ playerController.playerSpeed * 2.5);
+ },
+ onLongPressEnd: (_) {
+ setState(() {
+ showPlaySpeed = false;
+ });
+ playerController.setPlaybackSpeed(
+ playerController.playerSpeed / 2.5);
+ },
+ child: Container(
+ color: Colors.transparent,
+ width: double.infinity,
+ height: double.infinity,
),
+ ),
- // 播放器手势控制
- Positioned.fill(
- left: 16,
- top: 25,
- right: 15,
- bottom: 15,
- child: Utils.isDesktop()
- ? Container()
- : GestureDetector(
- onHorizontalDragUpdate:
- (DragUpdateDetails details) {
- setState(() {
- showPosition = true;
- });
- if (playerTimer != null) {
- // debugPrint('检测到拖动, 定时器取消');
- playerTimer!.cancel();
- }
- playerController.pause();
- final double scale = 180000 /
- MediaQuery.sizeOf(context)
- .width;
- playerController.currentPosition =
- Duration(
- milliseconds:
- playerController
- .currentPosition
- .inMilliseconds +
- (details.delta.dx *
- scale)
- .round());
- }, onHorizontalDragEnd:
- (DragEndDetails details) {
- playerController.play();
- playerController.seek(
- playerController
- .currentPosition);
- playerTimer = getPlayerTimer();
+ // 播放器手势控制
+ Positioned.fill(
+ left: 16,
+ top: 25,
+ right: 15,
+ bottom: 15,
+ child: Utils.isDesktop()
+ ? Container()
+ : GestureDetector(onHorizontalDragUpdate:
+ (DragUpdateDetails details) {
+ setState(() {
+ showPosition = true;
+ });
+ if (playerTimer != null) {
+ // debugPrint('检测到拖动, 定时器取消');
+ playerTimer!.cancel();
+ }
+ playerController.pause();
+ final double scale = 180000 /
+ MediaQuery.sizeOf(context).width;
+ playerController.currentPosition =
+ Duration(
+ milliseconds: playerController
+ .currentPosition
+ .inMilliseconds +
+ (details.delta.dx * scale)
+ .round());
+ }, onHorizontalDragEnd:
+ (DragEndDetails details) {
+ playerController.play();
+ playerController.seek(
+ playerController.currentPosition);
+ playerTimer = getPlayerTimer();
+ setState(() {
+ showPosition = false;
+ });
+ }, onVerticalDragUpdate:
+ (DragUpdateDetails details) async {
+ final double totalWidth =
+ MediaQuery.sizeOf(context).width;
+ final double totalHeight =
+ MediaQuery.sizeOf(context).height;
+ final double tapPosition =
+ details.localPosition.dx;
+ final double sectionWidth =
+ totalWidth / 2;
+ final double delta = details.delta.dy;
+
+ /// 非全屏时禁用
+ if (!videoPageController
+ .androidFullscreen) {
+ return;
+ }
+ if (tapPosition < sectionWidth) {
+ // 左边区域
setState(() {
- showPosition = false;
+ showBrightness = true;
});
- }, onVerticalDragUpdate:
- (DragUpdateDetails
- details) async {
- final double totalWidth =
- MediaQuery.sizeOf(context)
- .width;
- final double totalHeight =
- MediaQuery.sizeOf(context)
- .height;
- final double tapPosition =
- details.localPosition.dx;
- final double sectionWidth =
- totalWidth / 2;
- final double delta =
- details.delta.dy;
-
- /// 非全屏时禁用
- if (!videoPageController
- .androidFullscreen) {
- return;
- }
- if (tapPosition < sectionWidth) {
- // 左边区域
- setState(() {
- showBrightness = true;
- });
- try {
- playerController.brightness =
- await ScreenBrightness()
- .current;
- } catch (e) {
- KazumiLogger().log(
- Level.error, e.toString());
- }
- final double level =
- (totalHeight) * 3;
- final double brightness =
- playerController.brightness -
- delta / level;
- final double result =
- brightness.clamp(0.0, 1.0);
- setBrightness(result);
- } else {
- // 右边区域
- setState(() {
- showVolume = true;
- });
- final double level =
- (totalHeight) * 3;
- final double volume =
- playerController.volume -
- delta / level;
- final double result =
- volume.clamp(0.0, 1.0);
- setVolume(result);
- playerController.volume = result;
+ try {
+ playerController.brightness =
+ await ScreenBrightness()
+ .current;
+ } catch (e) {
+ KazumiLogger().log(
+ Level.error, e.toString());
}
- }, onVerticalDragEnd:
- (DragEndDetails details) {
+ final double level =
+ (totalHeight) * 3;
+ final double brightness =
+ playerController.brightness -
+ delta / level;
+ final double result =
+ brightness.clamp(0.0, 1.0);
+ setBrightness(result);
+ } else {
+ // 右边区域
setState(() {
- showVolume = false;
- showBrightness = false;
+ showVolume = true;
});
- })),
- // 顶部进度条
- Positioned(
- top: 25,
- width: 200,
- child: showPosition
- ? Wrap(
- alignment: WrapAlignment.center,
- children: <Widget>[
- Container(
+ final double level =
+ (totalHeight) * 3;
+ final double volume =
+ playerController.volume -
+ delta / level;
+ final double result =
+ volume.clamp(0.0, 1.0);
+ setVolume(result);
+ playerController.volume = result;
+ }
+ }, onVerticalDragEnd:
+ (DragEndDetails details) {
+ setState(() {
+ showVolume = false;
+ showBrightness = false;
+ });
+ })),
+ // 顶部进度条
+ Positioned(
+ top: 25,
+ width: 200,
+ child: showPosition
+ ? Wrap(
+ alignment: WrapAlignment.center,
+ children: <Widget>[
+ Container(
+ padding:
+ const EdgeInsets.all(8.0),
+ decoration: BoxDecoration(
+ color: Colors.black
+ .withOpacity(0.5),
+ borderRadius:
+ BorderRadius.circular(
+ 8.0), // 圆角
+ ),
+ child: Text(
+ playerController.currentPosition
+ .compareTo(
+ playerController
+ .mediaPlayer
+ .value
+ .position) >
+ 0
+ ? '快进 ${playerController.currentPosition.inSeconds - playerController.mediaPlayer.value.position.inSeconds} 秒'
+ : '快退 ${playerController.mediaPlayer.value.position.inSeconds - playerController.currentPosition.inSeconds} 秒',
+ style: const TextStyle(
+ color: Colors.white,
+ ),
+ ),
+ ),
+ ],
+ )
+ : Container()),
+ // 顶部播放速度条
+ Positioned(
+ top: 25,
+ child: showPlaySpeed
+ ? Wrap(
+ alignment: WrapAlignment.center,
+ children: <Widget>[
+ Container(
+ padding:
+ const EdgeInsets.all(8.0),
+ decoration: BoxDecoration(
+ color: Colors.black
+ .withOpacity(0.5),
+ borderRadius:
+ BorderRadius.circular(
+ 8.0), // 圆角
+ ),
+ child: const Row(
+ children: <Widget>[
+ Icon(Icons.fast_forward,
+ color: Colors.white),
+ Text(
+ ' 倍速播放',
+ style: TextStyle(
+ color: Colors.white,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ )
+ : Container()),
+ // 亮度条
+ Positioned(
+ top: 25,
+ child: showBrightness
+ ? Wrap(
+ alignment: WrapAlignment.center,
+ children: <Widget>[
+ Container(
padding:
const EdgeInsets.all(8.0),
decoration: BoxDecoration(
@@ -739,33 +850,30 @@ class _PlayerItemState extends State<PlayerItem>
BorderRadius.circular(
8.0), // 圆角
),
- child: Text(
- playerController
- .currentPosition
- .compareTo(
- playerController
- .mediaPlayer
- .value
- .position) >
- 0
- ? '快进 ${playerController.currentPosition.inSeconds - playerController.mediaPlayer.value.position.inSeconds} 秒'
- : '快退 ${playerController.mediaPlayer.value.position.inSeconds - playerController.currentPosition.inSeconds} 秒',
- style: const TextStyle(
- color: Colors.white,
- ),
- ),
- ),
- ],
- )
- : Container()),
- // 顶部播放速度条
- Positioned(
- top: 25,
- child: showPlaySpeed
- ? Wrap(
- alignment: WrapAlignment.center,
- children: <Widget>[
- Container(
+ child: Row(
+ children: <Widget>[
+ const Icon(
+ Icons.brightness_7,
+ color: Colors.white),
+ Text(
+ ' ${(playerController.brightness * 100).toInt()} %',
+ style: const TextStyle(
+ color: Colors.white,
+ ),
+ ),
+ ],
+ )),
+ ],
+ )
+ : Container()),
+ // 音量条
+ Positioned(
+ top: 25,
+ child: showVolume
+ ? Wrap(
+ alignment: WrapAlignment.center,
+ children: <Widget>[
+ Container(
padding:
const EdgeInsets.all(8.0),
decoration: BoxDecoration(
@@ -775,367 +883,283 @@ class _PlayerItemState extends State<PlayerItem>
BorderRadius.circular(
8.0), // 圆角
),
- child: const Row(
+ child: Row(
children: <Widget>[
- Icon(Icons.fast_forward,
+ const Icon(
+ Icons.volume_down,
color: Colors.white),
Text(
- ' 倍速播放',
- style: TextStyle(
+ ' ${(playerController.volume * 100).toInt()}%',
+ style: const TextStyle(
color: Colors.white,
),
),
],
- ),
- ),
- ],
- )
- : Container()),
- // 亮度条
- Positioned(
- top: 25,
- child: showBrightness
- ? Wrap(
- alignment: WrapAlignment.center,
- children: <Widget>[
- Container(
- padding:
- const EdgeInsets.all(8.0),
- decoration: BoxDecoration(
- color: Colors.black
- .withOpacity(0.5),
- borderRadius:
- BorderRadius.circular(
- 8.0), // 圆角
- ),
- child: Row(
- children: <Widget>[
- const Icon(
- Icons.brightness_7,
- color: Colors.white),
- Text(
- ' ${(playerController.brightness * 100).toInt()} %',
- style: const TextStyle(
- color: Colors.white,
- ),
- ),
- ],
- )),
- ],
- )
- : Container()),
- // 音量条
- Positioned(
- top: 25,
- child: showVolume
- ? Wrap(
- alignment: WrapAlignment.center,
- children: <Widget>[
- Container(
- padding:
- const EdgeInsets.all(8.0),
- decoration: BoxDecoration(
- color: Colors.black
- .withOpacity(0.5),
- borderRadius:
- BorderRadius.circular(
- 8.0), // 圆角
- ),
- child: Row(
- children: <Widget>[
- const Icon(
- Icons.volume_down,
- color: Colors.white),
- Text(
- ' ${(playerController.volume * 100).toInt()}%',
- style: const TextStyle(
- color: Colors.white,
- ),
- ),
- ],
- )),
- ],
- )
- : Container()),
- // 弹幕面板
- Positioned(
- top: 0,
- left: 0,
- right: 0,
- height: videoPageController.androidFullscreen
- ? MediaQuery.sizeOf(context).height *
- danmakuArea
- : (MediaQuery.sizeOf(context).width *
- 9 /
- 16 *
- danmakuArea),
- child: DanmakuScreen(
- key: _danmuKey,
- createdController: (DanmakuController e) {
- danmakuController = e;
- playerController.danmakuController = e;
- // debugPrint('弹幕控制器创建成功');
- },
- option: DanmakuOption(
- hideTop: _hideTop,
- hideScroll: _hideScroll,
- hideBottom: _hideBottom,
- opacity: _opacity,
- fontSize: _fontSize,
- duration: _duration.toInt(),
- showStroke: _border,
- massiveMode: _massiveMode,
- ),
+ )),
+ ],
+ )
+ : Container()),
+ // 弹幕面板
+ Positioned(
+ top: 0,
+ left: 0,
+ right: 0,
+ height: videoPageController.androidFullscreen
+ ? MediaQuery.sizeOf(context).height *
+ danmakuArea
+ : (MediaQuery.sizeOf(context).width *
+ 9 /
+ 16 *
+ danmakuArea),
+ child: DanmakuScreen(
+ key: _danmuKey,
+ createdController: (DanmakuController e) {
+ danmakuController = e;
+ playerController.danmakuController = e;
+ // debugPrint('弹幕控制器创建成功');
+ },
+ option: DanmakuOption(
+ hideTop: _hideTop,
+ hideScroll: _hideScroll,
+ hideBottom: _hideBottom,
+ opacity: _opacity,
+ fontSize: _fontSize,
+ duration: _duration.toInt(),
+ showStroke: _border,
+ massiveMode: _massiveMode,
),
),
+ ),
- // 自定义顶部组件
- (showPositioned ||
- !playerController
- .mediaPlayer.value.isPlaying)
- ? Positioned(
- top: 0,
- left: 0,
- right: 0,
- child: Row(
- children: [
- IconButton(
- color: Colors.white,
- icon:
- const Icon(Icons.arrow_back),
- onPressed: () {
- onBackPressed(context);
- },
- ),
- // 拖动条
- const Expanded(
- child: dtb.DragToMoveArea(
- child: SizedBox(height: 40)),
- ),
- TextButton(
- style: ButtonStyle(
- padding:
- WidgetStateProperty.all(
- EdgeInsets.zero),
- ),
- onPressed: () {
- // 倍速播放
- showSetSpeedSheet();
- },
- child: Text(
- '${playerController.playerSpeed}X',
- style: const TextStyle(
- color: Colors.white,
- fontSize: 12,
- ),
- ),
- ),
- IconButton(
- color: Colors.white,
- icon: const Icon(Icons.cast),
- onPressed: () {
- RemotePlay().castVideo(context);
- },
- ),
- // 追番
- IconButton(
- icon: Icon(
- isFavorite
- ? Icons.favorite
- : Icons.favorite_outline,
- color: Colors.white),
- onPressed: () async {
- if (isFavorite) {
- favoriteController
- .deleteFavorite(
- infoController
- .bangumiItem);
- SmartDialog.showToast(
- '取消追番成功');
- } else {
- favoriteController
- .addFavorite(
- infoController
- .bangumiItem);
- SmartDialog.showToast(
- '自己追的番要好好看完哦');
- }
- setState(() {
- isFavorite = !isFavorite;
- });
- },
- ),
- ],
+ // 自定义顶部组件
+ Positioned(
+ top: 0,
+ left: 0,
+ right: 0,
+ child: SlideTransition(
+ position: _topOffsetAnimation,
+ child: Row(
+ children: [
+ IconButton(
+ color: Colors.white,
+ icon: const Icon(Icons.arrow_back),
+ onPressed: () {
+ onBackPressed(context);
+ },
+ ),
+ // 拖动条
+ const Expanded(
+ child: dtb.DragToMoveArea(
+ child: SizedBox(height: 40)),
+ ),
+ TextButton(
+ style: ButtonStyle(
+ padding: WidgetStateProperty.all(
+ EdgeInsets.zero),
+ ),
+ onPressed: () {
+ // 倍速播放
+ showSetSpeedSheet();
+ },
+ child: Text(
+ '${playerController.playerSpeed}X',
+ style: const TextStyle(
+ color: Colors.white,
+ fontSize: 12,
+ ),
),
- )
- : Container(),
+ ),
+ IconButton(
+ color: Colors.white,
+ icon: const Icon(Icons.cast),
+ onPressed: () {
+ RemotePlay().castVideo(context);
+ },
+ ),
+ // 追番
+ IconButton(
+ icon: Icon(
+ isFavorite
+ ? Icons.favorite
+ : Icons.favorite_outline,
+ color: Colors.white),
+ onPressed: () async {
+ if (isFavorite) {
+ favoriteController.deleteFavorite(
+ infoController.bangumiItem);
+ SmartDialog.showToast('取消追番成功');
+ } else {
+ favoriteController.addFavorite(
+ infoController.bangumiItem);
+ SmartDialog.showToast(
+ '自己追的番要好好看完哦');
+ }
+ setState(() {
+ isFavorite = !isFavorite;
+ });
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
- // 自定义播放器底部组件
- (showPositioned ||
- !playerController
- .mediaPlayer.value.isPlaying)
- ? Positioned(
- bottom: 0,
- left: 0,
- right: 0,
- child: Row(
- children: [
- IconButton(
+ // 自定义播放器底部组件
+ Positioned(
+ bottom: 0,
+ left: 0,
+ right: 0,
+ child: SlideTransition(
+ position: _bottomOffsetAnimation,
+ child: Row(
+ children: [
+ IconButton(
+ color: Colors.white,
+ icon: Icon(playerController.playing
+ ? Icons.pause
+ : Icons.play_arrow),
+ onPressed: () {
+ if (playerController.playing) {
+ playerController.pause();
+ } else {
+ playerController.play();
+ }
+ },
+ ),
+ // 更换选集
+ (videoPageController.androidFullscreen ==
+ true)
+ ? IconButton(
color: Colors.white,
- icon: Icon(
- playerController.playing
- ? Icons.pause
- : Icons.play_arrow),
+ icon: const Icon(Icons.skip_next),
onPressed: () {
- if (playerController.playing) {
- playerController.pause();
- } else {
- playerController.play();
+ if (videoPageController
+ .currentEspisode ==
+ videoPageController
+ .roadList[
+ videoPageController
+ .currentRoad]
+ .data
+ .length) {
+ SmartDialog.showToast(
+ '已经是最新一集',
+ displayType:
+ SmartToastType.last);
+ return;
}
+ SmartDialog.showToast(
+ '正在加载第 ${videoPageController.currentEspisode + 1} 话');
+ videoPageController.changeEpisode(
+ videoPageController
+ .currentEspisode +
+ 1,
+ currentRoad:
+ videoPageController
+ .currentRoad);
},
- ),
- // 更换选集
- (videoPageController
- .androidFullscreen ==
- true)
- ? IconButton(
- color: Colors.white,
- icon: const Icon(
- Icons.skip_next),
- onPressed: () {
- if (videoPageController
- .currentEspisode ==
- videoPageController
- .roadList[
- videoPageController
- .currentRoad]
- .data
- .length) {
- SmartDialog.showToast(
- '已经是最新一集',
- displayType:
- SmartToastType
- .last);
- return;
- }
- SmartDialog.showToast(
- '正在加载第 ${videoPageController.currentEspisode + 1} 话');
- videoPageController.changeEpisode(
- videoPageController
- .currentEspisode +
- 1,
- currentRoad:
- videoPageController
- .currentRoad);
- },
- )
- : Container(),
- Expanded(
- child: ProgressBar(
- timeLabelLocation:
- TimeLabelLocation.none,
- progress: playerController
- .currentPosition,
- buffered:
- playerController.buffer,
- total:
- playerController.duration,
- onSeek: (duration) {
- if (playerTimer != null) {
- playerTimer!.cancel();
- }
- playerController.currentPosition = duration;
- playerController
- .seek(duration);
- playerTimer = getPlayerTimer();
- },
+ )
+ : Container(),
+ Expanded(
+ child: ProgressBar(
+ timeLabelLocation:
+ TimeLabelLocation.none,
+ progress:
+ playerController.currentPosition,
+ buffered: playerController.buffer,
+ total: playerController.duration,
+ onSeek: (duration) {
+ if (playerTimer != null) {
+ playerTimer!.cancel();
+ }
+ playerController.currentPosition =
+ duration;
+ playerController.seek(duration);
+ playerTimer = getPlayerTimer();
+ },
+ ),
+ ),
+ ((Utils.isCompact()) &&
+ !videoPageController
+ .androidFullscreen)
+ ? Container()
+ : Container(
+ padding: const EdgeInsets.only(
+ left: 10.0),
+ child: Text(
+ Utils.durationToString(
+ playerController
+ .currentPosition) +
+ " / " +
+ Utils.durationToString(
+ playerController
+ .duration),
+ style: TextStyle(
+ color: Colors.white,
+ fontSize: !Utils.isCompact()
+ ? 16.0
+ : 12.0,
+ ),
),
),
- ((Utils.isCompact()) &&
- !videoPageController
- .androidFullscreen)
- ? Container()
- : Container(
- padding:
- const EdgeInsets.only(
- left: 10.0),
- child: Text(
- Utils.durationToString(
- playerController
- .currentPosition) +
- " / " +
- Utils.durationToString(
- playerController
- .duration),
- style: TextStyle(
- color: Colors.white,
- fontSize:
- !Utils.isCompact()
- ? 16.0
- : 12.0,
- ),
- ),
- ),
- // 弹幕相关
- // (playerController.androidFullscreen ==
- // true &&
- // playerController.danmakuOn ==
- // true)
- // ? IconButton(
- // color: Colors.white,
- // icon:
- // const Icon(Icons.notes),
- // onPressed: () {
- // if (playerController
- // .danDanmakus
- // .length ==
- // 0) {
- // SmartDialog.showToast(
- // '当前剧集不支持弹幕发送的说',
- // displayType:
- // SmartToastType
- // .last);
- // return;
- // }
- // showShootDanmakuSheet();
- // },
- // )
- // : Container(),
- IconButton(
- color: Colors.white,
- icon: Icon(playerController
- .danmakuOn
- ? Icons.comment
- : Icons.comments_disabled),
- onPressed: () {
- _handleDanmaku();
- },
- ),
- IconButton(
- color: Colors.white,
- icon: Icon(videoPageController
- .androidFullscreen
- ? Icons.fullscreen_exit
- : Icons.fullscreen),
- onPressed: () {
- _handleFullscreen();
- },
- ),
- ],
- ),
- )
- : Container(),
- ]),
- ),
+ // 弹幕相关
+ // (playerController.androidFullscreen ==
+ // true &&
+ // playerController.danmakuOn ==
+ // true)
+ // ? IconButton(
+ // color: Colors.white,
+ // icon:
+ // const Icon(Icons.notes),
+ // onPressed: () {
+ // if (playerController
+ // .danDanmakus
+ // .length ==
+ // 0) {
+ // SmartDialog.showToast(
+ // '当前剧集不支持弹幕发送的说',
+ // displayType:
+ // SmartToastType
+ // .last);
+ // return;
+ // }
+ // showShootDanmakuSheet();
+ // },
+ // )
+ // : Container(),
+ IconButton(
+ color: Colors.white,
+ icon: Icon(playerController.danmakuOn
+ ? Icons.comment
+ : Icons.comments_disabled),
+ onPressed: () {
+ _handleDanmaku();
+ },
+ ),
+ IconButton(
+ color: Colors.white,
+ icon: Icon(videoPageController
+ .androidFullscreen
+ ? Icons.fullscreen_exit
+ : Icons.fullscreen),
+ onPressed: () {
+ _handleFullscreen();
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ]),
),
),
),
),
),
),
+ ),
+ )
// SizedBox(child: Text("${videoController.androidFullscreen}")),
- ],
- );
+ ;
}),
),
),
diff --git a/lib/pages/video/video_controller.dart b/lib/pages/video/video_controller.dart
index 3a706afc..4a378004 100644
--- a/lib/pages/video/video_controller.dart
+++ b/lib/pages/video/video_controller.dart
@@ -123,12 +123,6 @@ abstract class _VideoPageController with Store {
if (Utils.isCompact()) {
verticalScreen();
}
- } else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
- await const MethodChannel('com.alexmercerind/media_kit_video')
- .invokeMethod(
- 'Utils.ExitNativeFullscreen',
- );
- // verticalScreen();
}
} catch (exception, stacktrace) {
// debugPrint(exception.toString());
@@ -155,11 +149,6 @@ abstract class _VideoPageController with Store {
],
);
// await AutoOrientation.landscapeAutoMode(forceSensor: true);
- } else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
- await const MethodChannel('com.alexmercerind/media_kit_video')
- .invokeMethod(
- 'Utils.EnterNativeFullscreen',
- );
}
} catch (exception, stacktrace) {
// debugPrint(exception.toString());