From 49192fff00de5c62095b198e3172258b93729be7 Mon Sep 17 00:00:00 2001 From: Predidit <34627277+Predidit@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:26:35 +0800 Subject: [PATCH] better player --- lib/pages/video/video_page.dart | 223 ++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 100 deletions(-) diff --git a/lib/pages/video/video_page.dart b/lib/pages/video/video_page.dart index ac25498..a5a108e 100644 --- a/lib/pages/video/video_page.dart +++ b/lib/pages/video/video_page.dart @@ -170,115 +170,121 @@ class _VideoPageState extends State with WindowListener { 1.75, 2.0 ]; - SmartDialog.show(useAnimation: false, builder: (context) { - return AlertDialog( - title: const Text('播放速度'), - content: StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return Wrap( - spacing: 8, - runSpacing: 2, - children: [ - for (final double i in speedsList) ...[ - if (i == currentSpeed) ...[ - FilledButton( - onPressed: () async { - await videoController.setPlaybackSpeed(i); - SmartDialog.dismiss(); - }, - child: Text(i.toString()), - ), - ] else ...[ - FilledButton.tonal( - onPressed: () async { - await videoController.setPlaybackSpeed(i); - SmartDialog.dismiss(); - }, - child: Text(i.toString()), - ), - ] - ] + SmartDialog.show( + useAnimation: false, + builder: (context) { + return AlertDialog( + title: const Text('播放速度'), + content: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return Wrap( + spacing: 8, + runSpacing: 2, + children: [ + for (final double i in speedsList) ...[ + if (i == currentSpeed) ...[ + FilledButton( + onPressed: () async { + await videoController.setPlaybackSpeed(i); + SmartDialog.dismiss(); + }, + child: Text(i.toString()), + ), + ] else ...[ + FilledButton.tonal( + onPressed: () async { + await videoController.setPlaybackSpeed(i); + SmartDialog.dismiss(); + }, + child: Text(i.toString()), + ), + ] + ] + ], + ); + }), + actions: [ + TextButton( + onPressed: () => SmartDialog.dismiss(), + child: Text( + '取消', + style: + TextStyle(color: Theme.of(context).colorScheme.outline), + ), + ), + TextButton( + onPressed: () async { + await videoController.setPlaybackSpeed(1.0); + SmartDialog.dismiss(); + }, + child: const Text('默认速度'), + ), ], ); - }), - actions: [ - TextButton( - onPressed: () => SmartDialog.dismiss(), - child: Text( - '取消', - style: TextStyle(color: Theme.of(context).colorScheme.outline), - ), - ), - TextButton( - onPressed: () async { - await videoController.setPlaybackSpeed(1.0); - SmartDialog.dismiss(); - }, - child: const Text('默认速度'), - ), - ], - ); - }); + }); } /// 发送弹幕 由于接口限制, 暂时未提交云端 void showShootDanmakuSheet() { final TextEditingController textController = TextEditingController(); bool isSending = false; // 追踪是否正在发送 - SmartDialog.show(useAnimation: false, builder: (context) { - return AlertDialog( - title: const Text('发送弹幕'), - content: StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return TextField( - controller: textController, - ); - }), - actions: [ - TextButton( - onPressed: () => SmartDialog.dismiss(), - child: Text( - '取消', - style: TextStyle(color: Theme.of(context).colorScheme.outline), - ), - ), - StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return TextButton( - onPressed: isSending - ? null - : () async { - final String msg = textController.text; - if (msg.isEmpty) { - SmartDialog.showToast('弹幕内容不能为空'); - return; - } else if (msg.length > 100) { - SmartDialog.showToast('弹幕内容不能超过100个字符'); - return; - } - setState(() { - isSending = true; // 开始发送,更新状态 - }); - // Todo 接口方限制 + SmartDialog.show( + useAnimation: false, + builder: (context) { + return AlertDialog( + title: const Text('发送弹幕'), + content: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return TextField( + controller: textController, + ); + }), + actions: [ + TextButton( + onPressed: () => SmartDialog.dismiss(), + child: Text( + '取消', + style: + TextStyle(color: Theme.of(context).colorScheme.outline), + ), + ), + StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return TextButton( + onPressed: isSending + ? null + : () async { + final String msg = textController.text; + if (msg.isEmpty) { + SmartDialog.showToast('弹幕内容不能为空'); + return; + } else if (msg.length > 100) { + SmartDialog.showToast('弹幕内容不能超过100个字符'); + return; + } + setState(() { + isSending = true; // 开始发送,更新状态 + }); + // Todo 接口方限制 - setState(() { - isSending = false; // 发送结束,更新状态 - }); - SmartDialog.showToast('发送成功'); - danmakuController.addItems([ - DanmakuItem( - msg, - // color: Colors.purple, - ) - ]); - SmartDialog.dismiss(); - }, - child: Text(isSending ? '发送中...' : '发送'), - ); - }) - ], - ); - }); + setState(() { + isSending = false; // 发送结束,更新状态 + }); + SmartDialog.showToast('发送成功'); + danmakuController.addItems([ + DanmakuItem( + msg, + // color: Colors.purple, + ) + ]); + SmartDialog.dismiss(); + }, + child: Text(isSending ? '发送中...' : '发送'), + ); + }) + ], + ); + }); } @override @@ -617,6 +623,23 @@ class _VideoPageState extends State with WindowListener { } }, ), + (videoController.androidFullscreen == true) + ? IconButton( + color: Colors.white, + icon: const Icon(Icons.skip_next), + onPressed: () { + if (videoController.episode == + videoController + .token.length) { + SmartDialog.showToast( + '已经是最新一集'); + return; + } + videoController.changeEpisode( + videoController.episode + 1); + }, + ) + : Container(), Expanded( child: ProgressBar( timeLabelLocation: