Skip to content

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

refactor of mobile and tablet player fullscreen panel

ErBW_sa5a41ed6fa2e
diff --git a/lib/pages/info/info_page.dart b/lib/pages/info/info_page.dart
index 5be22bfa..af9778b4 100644
--- a/lib/pages/info/info_page.dart
+++ b/lib/pages/info/info_page.dart
@@ -225,7 +225,6 @@ class _InfoPageState extends State<InfoPage>
onPressed: () async {
showModalBottomSheet(
isScrollControlled: true,
- enableDrag: false,
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 3 / 4,
maxWidth: (Utils.isDesktop() || Utils.isTablet())
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dart
index 41a975f2..a1198fe8 100644
--- a/lib/pages/player/player_item.dart
+++ b/lib/pages/player/player_item.dart
@@ -37,6 +37,7 @@ class PlayerItem extends StatefulWidget {
required this.changeEpisode,
required this.onBackPressed,
required this.keyboardFocus,
+ required this.sendDanmaku,
});
final VoidCallback openMenu;
@@ -44,6 +45,7 @@ class PlayerItem extends StatefulWidget {
final Future<void> Function(int episode, {int currentRoad, int offset})
changeEpisode;
final void Function(BuildContext) onBackPressed;
+ final void Function(String) sendDanmaku;
final FocusNode keyboardFocus;
@override
@@ -797,6 +799,7 @@ class _PlayerItemState extends State<PlayerItem>
animationController: animationController!,
keyboardFocus: widget.keyboardFocus,
handleHove: handleHove,
+ sendDanmaku: widget.sendDanmaku,
),
// 播放器手势控制
Positioned.fill(
diff --git a/lib/pages/player/player_item_panel.dart b/lib/pages/player/player_item_panel.dart
index bd523ae9..a860d75f 100644
--- a/lib/pages/player/player_item_panel.dart
+++ b/lib/pages/player/player_item_panel.dart
@@ -32,6 +32,7 @@ class PlayerItemPanel extends StatefulWidget {
required this.openMenu,
required this.keyboardFocus,
required this.handleHove,
+ required this.sendDanmaku,
});
final void Function(BuildContext) onBackPressed;
@@ -45,6 +46,7 @@ class PlayerItemPanel extends StatefulWidget {
final void Function() handleHove;
final AnimationController animationController;
final FocusNode keyboardFocus;
+ final void Function(String) sendDanmaku;
@override
State<PlayerItemPanel> createState() => _PlayerItemPanelState();
@@ -88,36 +90,13 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
playerController.danmakuOn = !playerController.danmakuOn;
}
- /// 发送弹幕 由于接口限制, 暂时未提交云端
- void sendDanmaku() async {
- widget.keyboardFocus.requestFocus();
- if (playerController.danDanmakus.isEmpty) {
- KazumiDialog.showToast(
- message: '当前剧集不支持弹幕发送的说',
- );
- return;
- }
- final String msg = textController.text;
- if (msg.isEmpty) {
- KazumiDialog.showToast(message: '弹幕内容为空');
- return;
- } else if (msg.length > 100) {
- KazumiDialog.showToast(message: '弹幕内容过长');
- return;
- }
- // Todo 接口方限制
-
- KazumiDialog.showToast(message: '发送成功');
- playerController.danmakuController
- .addDanmaku(DanmakuContentItem(msg, selfSend: true));
- textController.clear();
- }
-
Widget danmakuTextField() {
return Container(
- constraints: const BoxConstraints(maxWidth: 500, maxHeight: 33),
+ constraints: Utils.isDesktop()
+ ? const BoxConstraints(maxWidth: 500, maxHeight: 33)
+ : const BoxConstraints(maxHeight: 33),
child: TextField(
- style: const TextStyle(fontSize: 15),
+ style: TextStyle(fontSize: Utils.isDesktop() ? 15 : 13),
controller: textController,
textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
@@ -126,17 +105,19 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
fillColor: Colors.white30,
floatingLabelBehavior: FloatingLabelBehavior.never,
hintText: playerController.danmakuOn ? '发个友善的弹幕见证当下' : '已关闭弹幕',
- hintStyle: const TextStyle(fontSize: 15),
+ hintStyle: TextStyle(fontSize: Utils.isDesktop() ? 15 : 13),
alignLabelWithHint: true,
- contentPadding:
- const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
- border: const OutlineInputBorder(
+ contentPadding: EdgeInsets.symmetric(
+ vertical: 8, horizontal: Utils.isDesktop() ? 8 : 12),
+ border: OutlineInputBorder(
borderSide: BorderSide.none,
- borderRadius: BorderRadius.all(Radius.circular(8)),
+ borderRadius:
+ BorderRadius.all(Radius.circular(Utils.isDesktop() ? 8 : 20)),
),
suffixIcon: TextButton(
onPressed: () {
- sendDanmaku();
+ widget.sendDanmaku(textController.text);
+ textController.clear();
},
style: TextButton.styleFrom(
foregroundColor: playerController.danmakuOn
@@ -146,7 +127,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).disabledColor,
shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
+ borderRadius: BorderRadius.circular(Utils.isDesktop() ? 8 : 20),
),
),
child: const Text('发送'),
@@ -155,11 +136,12 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
onChanged: (_) {
widget.handleHove();
},
- onSubmitted: (_) {
- sendDanmaku();
+ onSubmitted: (msg) {
+ widget.sendDanmaku(msg);
+ textController.clear();
},
onTapOutside: (_) {
- widget.keyboardFocus.requestFocus(FocusNode());
+ widget.keyboardFocus.requestFocus();
},
),
);
@@ -654,7 +636,22 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
child: SlideTransition(
position: bottomOffsetAnimation,
child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
+ if (!Utils.isDesktop() && !Utils.isTablet())
+ Container(
+ padding: const EdgeInsets.only(left: 10.0, bottom: 10),
+ child: Text(
+ "${Utils.durationToString(playerController.currentPosition)} / ${Utils.durationToString(playerController.duration)}",
+ style: const TextStyle(
+ color: Colors.white,
+ fontSize: 12.0,
+ fontFeatures: [
+ FontFeature.tabularFigures(),
+ ],
+ ),
+ ),
+ ),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: ProgressBar(
@@ -692,96 +689,125 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
},
),
// 更换选集
- (videoPageController.isFullscreen ||
- Utils.isTablet() ||
- Utils.isDesktop())
- ? IconButton(
+ if (videoPageController.isFullscreen ||
+ Utils.isTablet() ||
+ Utils.isDesktop())
+ IconButton(
+ color: Colors.white,
+ icon: const Icon(Icons.skip_next_rounded),
+ onPressed: () {
+ if (videoPageController.loading) {
+ return;
+ }
+ if (videoPageController.currentEpisode ==
+ videoPageController
+ .roadList[
+ videoPageController.currentRoad]
+ .data
+ .length) {
+ KazumiDialog.showToast(
+ message: '已经是最新一集',
+ );
+ return;
+ }
+ KazumiDialog.showToast(
+ message:
+ '正在加载${videoPageController.roadList[videoPageController.currentRoad].identifier[videoPageController.currentEpisode]}');
+ widget.changeEpisode(
+ videoPageController.currentEpisode + 1,
+ currentRoad:
+ videoPageController.currentRoad);
+ },
+ ),
+ if (Utils.isDesktop() || Utils.isTablet())
+ Container(
+ padding: const EdgeInsets.only(left: 10.0),
+ child: Text(
+ "${Utils.durationToString(playerController.currentPosition)} / ${Utils.durationToString(playerController.duration)}",
+ style: const TextStyle(
color: Colors.white,
- icon: const Icon(Icons.skip_next_rounded),
- onPressed: () {
- if (videoPageController.loading) {
- return;
- }
- if (videoPageController.currentEpisode ==
- videoPageController
- .roadList[
- videoPageController.currentRoad]
- .data
- .length) {
- KazumiDialog.showToast(
- message: '已经是最新一集',
- );
- return;
- }
- KazumiDialog.showToast(
- message:
- '正在加载${videoPageController.roadList[videoPageController.currentRoad].identifier[videoPageController.currentEpisode]}');
- widget.changeEpisode(
- videoPageController.currentEpisode + 1,
- currentRoad:
- videoPageController.currentRoad);
- },
- )
- : Container(),
- ((Utils.isCompact()) &&
- !videoPageController.isFullscreen)
- ? 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,
- fontFeatures: const [
- FontFeature.tabularFigures(),
+ fontSize: 16.0,
+ fontFeatures: [
+ FontFeature.tabularFigures(),
+ ],
+ ),
+ ),
+ ),
+ if (Utils.isDesktop())
+ Expanded(
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ bool isSpaceEnough =
+ constraints.maxWidth > 600;
+ return Center(
+ child: Row(
+ mainAxisAlignment:
+ MainAxisAlignment.center,
+ children: [
+ IconButton(
+ color: Colors.white,
+ icon: Icon(playerController.danmakuOn
+ ? Icons.subtitles_rounded
+ : Icons.subtitles_off_rounded),
+ onPressed: () {
+ _handleDanmaku();
+ setState(() {});
+ },
+ tooltip: playerController.danmakuOn
+ ? '关闭弹幕(d)'
+ : '打开弹幕(d)',
+ ),
+ IconButton(
+ tooltip: '弹幕设置',
+ onPressed: () {
+ widget.keyboardFocus.requestFocus();
+ KazumiDialog.show(
+ builder: (context) {
+ return DanmakuSettingsWindow(
+ danmakuController:
+ playerController
+ .danmakuController);
+ });
+ },
+ color: Colors.white,
+ icon: const Icon(Icons.tune_rounded),
+ ),
+ if (isSpaceEnough) danmakuTextField(),
],
),
- ),
- ),
- Expanded(
- child: LayoutBuilder(
- builder: (context, constraints) {
- bool isSpaceEnough = constraints.maxWidth > 600;
- return Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- IconButton(
- color: Colors.white,
- icon: Icon(playerController.danmakuOn
- ? Icons.subtitles_rounded
- : Icons.subtitles_off_rounded),
- onPressed: () {
- _handleDanmaku();
- setState(() {});
- },
- tooltip: playerController.danmakuOn
- ? '关闭弹幕(d)'
- : '打开弹幕(d)',
- ),
- IconButton(
- tooltip: '弹幕设置',
- onPressed: () {
- widget.keyboardFocus.requestFocus();
- KazumiDialog.show(builder: (context) {
- return DanmakuSettingsWindow(
- danmakuController:
- playerController
- .danmakuController);
- });
- },
- color: Colors.white,
- icon: const Icon(Icons.tune_rounded),
- ),
- if (isSpaceEnough) danmakuTextField(),
- ],
- ),
- );
+ );
+ },
+ ),
+ ),
+ if (!Utils.isDesktop()) ...[
+ IconButton(
+ color: Colors.white,
+ icon: Icon(playerController.danmakuOn
+ ? Icons.subtitles_rounded
+ : Icons.subtitles_off_rounded),
+ onPressed: () {
+ _handleDanmaku();
+ setState(() {});
},
+ tooltip: playerController.danmakuOn
+ ? '关闭弹幕(d)'
+ : '打开弹幕(d)',
),
- ),
+ IconButton(
+ tooltip: '弹幕设置',
+ onPressed: () {
+ widget.keyboardFocus.requestFocus();
+ KazumiDialog.show(builder: (context) {
+ return DanmakuSettingsWindow(
+ danmakuController:
+ playerController.danmakuController);
+ });
+ },
+ color: Colors.white,
+ icon: const Icon(Icons.tune_rounded),
+ ),
+ Expanded(child: danmakuTextField()),
+ ],
// 超分辨率
MenuAnchor(
builder: (BuildContext context,
@@ -810,10 +836,10 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
const EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
index + 1 == 1
- ? 'OFF'
+ ? '关闭'
: index + 1 == 2
- ? 'Efficiency'
- : 'Quality',
+ ? '效率档'
+ : '质量档',
style: TextStyle(
color: playerController
.superResolutionType ==
@@ -901,10 +927,10 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
const EdgeInsets.fromLTRB(0, 10, 10, 10),
child: Text(
index + 1 == 1
- ? 'AUTO'
+ ? '自动'
: index + 1 == 2
- ? 'COVER'
- : 'FILL',
+ ? '裁切填充'
+ : '拉伸填充',
style: TextStyle(
color: index + 1 ==
playerController.aspectRatioType
@@ -947,7 +973,8 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
],
),
),
- const SizedBox(height: 6),
+ if (Utils.isTablet() || Utils.isDesktop())
+ const SizedBox(height: 6),
],
),
),
diff --git a/lib/pages/video/video_page.dart b/lib/pages/video/video_page.dart
index 4a0b9c3b..912994a0 100644
--- a/lib/pages/video/video_page.dart
+++ b/lib/pages/video/video_page.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'package:canvas_danmaku/models/danmaku_content_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
@@ -219,6 +220,91 @@ class _VideoPageState extends State<VideoPage>
Navigator.of(context).pop();
}
+ /// 发送弹幕 由于接口限制, 暂时未提交云端
+ void sendDanmaku(String msg) async {
+ keyboardFocus.requestFocus();
+ if (playerController.danDanmakus.isEmpty) {
+ KazumiDialog.showToast(
+ message: '当前剧集不支持弹幕发送的说',
+ );
+ return;
+ }
+ if (msg.isEmpty) {
+ KazumiDialog.showToast(message: '弹幕内容为空');
+ return;
+ } else if (msg.length > 100) {
+ KazumiDialog.showToast(message: '弹幕内容过长');
+ return;
+ }
+ // Todo 接口方限制
+
+ KazumiDialog.showToast(message: '发送成功 $msg');
+ playerController.danmakuController
+ .addDanmaku(DanmakuContentItem(msg, selfSend: true));
+ }
+
+ void showMobileDanmakuInput() {
+ final TextEditingController textController = TextEditingController();
+ showModalBottomSheet(
+ shape: const BeveledRectangleBorder(),
+ isScrollControlled: true,
+ context: context,
+ builder: (context) {
+ return Padding(
+ padding: EdgeInsets.only(
+ bottom: MediaQuery.of(context).viewInsets.bottom,
+ left: 8,
+ ),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Expanded(
+ child: Container(
+ constraints: const BoxConstraints(maxHeight: 34),
+ child: TextField(
+ style: const TextStyle(fontSize: 15),
+ controller: textController,
+ autofocus: true,
+ textAlignVertical: TextAlignVertical.center,
+ decoration: const InputDecoration(
+ filled: true,
+ floatingLabelBehavior: FloatingLabelBehavior.never,
+ hintText: '发个友善的弹幕见证当下',
+ hintStyle: TextStyle(fontSize: 14),
+ alignLabelWithHint: true,
+ contentPadding:
+ EdgeInsets.symmetric(vertical: 8, horizontal: 12),
+ border: OutlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.all(Radius.circular(20)),
+ ),
+ ),
+ onSubmitted: (msg) {
+ sendDanmaku(msg);
+ textController.clear();
+ Navigator.pop(context);
+ },
+ ),
+ ),
+ ),
+ IconButton(
+ onPressed: () {
+ sendDanmaku(textController.text);
+ textController.clear();
+ Navigator.pop(context);
+ },
+ icon: Icon(
+ Icons.send_rounded,
+ color: Theme.of(context).colorScheme.primary,
+ ),
+ )
+ ],
+ ),
+ );
+ },
+ );
+ }
+
@override
Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -526,6 +612,7 @@ class _VideoPageState extends State<VideoPage>
changeEpisode: changeEpisode,
onBackPressed: onBackPressed,
keyboardFocus: keyboardFocus,
+ sendDanmaku: sendDanmaku,
),
),
@@ -729,22 +816,77 @@ class _VideoPageState extends State<VideoPage>
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- TabBar(
- dividerHeight: Utils.isDesktop() ? 0.5 : 0.2,
- isScrollable: true,
- tabAlignment: TabAlignment.start,
- labelPadding:
- const EdgeInsetsDirectional.only(start: 30, end: 30),
- onTap: (index) {
- if (index == 0) {
- menuJumpToCurrentEpisode();
- }
- },
- tabs: const [
- Tab(text: '选集'),
- Tab(text: '评论'),
+ Row(
+ children: [
+ TabBar(
+ dividerHeight: 0,
+ isScrollable: true,
+ tabAlignment: TabAlignment.start,
+ labelPadding:
+ const EdgeInsetsDirectional.only(start: 30, end: 30),
+ onTap: (index) {
+ if (index == 0) {
+ menuJumpToCurrentEpisode();
+ }
+ },
+ tabs: const [
+ Tab(text: '选集'),
+ Tab(text: '评论'),
+ ],
+ ),
+ if (!Utils.isDesktop() && !Utils.isTablet()) ...[
+ const Spacer(),
+ AnimatedContainer(
+ duration: const Duration(milliseconds: 200),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(25),
+ border: Border.all(
+ color: Theme.of(context).dividerColor,
+ width: 0.5,
+ ),
+ ),
+ width: playerController.danmakuOn ? 120 : 41,
+ height: 31,
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ if (playerController.danmakuOn)
+ Expanded(
+ child: GestureDetector(
+ onTap: () {
+ showMobileDanmakuInput();
+ },
+ child: Text(
+ ' 点我发弹幕',
+ softWrap: false,
+ overflow: TextOverflow.clip,
+ style: TextStyle(
+ color: Theme.of(context).colorScheme.outline,
+ ),
+ ),
+ ),
+ ),
+ IconButton(
+ iconSize: 20,
+ visualDensity: VisualDensity.compact,
+ onPressed: () {
+ playerController.danmakuOn =
+ !playerController.danmakuOn;
+ },
+ icon: Icon(
+ playerController.danmakuOn
+ ? Icons.subtitles
+ : Icons.subtitles_off_rounded,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ const SizedBox(width: 8),
],
),
+ Divider(height: Utils.isDesktop() ? 0.5 : 0.2),
Expanded(
child: TabBarView(
children: [