基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
feat: disable player animation to avoid falling into the gtk/flutter/mpv openGL context interoper hell
Predidit383aff08a291
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dartindex acd0b89e..beb3311b 100644--- a/lib/pages/player/player_item.dart+++ b/lib/pages/player/player_item.dart@@ -1304,6 +1304,10 @@ class _PlayerItemState extends State<PlayerItem>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,): SmallestPlayerItemPanel(onBackPressed: widget.onBackPressed,@@ -1325,6 +1329,7 @@ class _PlayerItemState extends State<PlayerItem>showSyncPlayRoomCreateDialog,showSyncPlayEndPointSwitchDialog:showSyncPlayEndPointSwitchDialog,+ disableAnimations: Platform.isLinux,),// 播放器手势控制Positioned.fill(diff --git a/lib/pages/player/player_item_panel.dart b/lib/pages/player/player_item_panel.dartindex 947bfdce..448f8384 100644--- a/lib/pages/player/player_item_panel.dart+++ b/lib/pages/player/player_item_panel.dart@@ -39,6 +39,7 @@ class PlayerItemPanel extends StatefulWidget {required this.showVideoInfo,required this.showSyncPlayRoomCreateDialog,required this.showSyncPlayEndPointSwitchDialog,+ this.disableAnimations = false,});final void Function(BuildContext) onBackPressed;@@ -59,6 +60,7 @@ class PlayerItemPanel extends StatefulWidget {final void Function() showVideoInfo;final void Function() showSyncPlayRoomCreateDialog;final void Function() showSyncPlayEndPointSwitchDialog;+ final bool disableAnimations;@overrideState<PlayerItemPanel> createState() => _PlayerItemPanelState();@@ -312,14 +314,6 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {@overrideWidget build(BuildContext context) {- final svgString = danmakuOnSvg.replaceFirst(- '00AEEC',- Theme.of(context)- .colorScheme- .primary- .toARGB32()- .toRadixString(16)- .substring(2));return Observer(builder: (context) {return Stack(alignment: Alignment.center,@@ -331,23 +325,40 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {left: 0,right: 0,child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: topOffsetAnimation,- child: Container(- height: 50,- decoration: const BoxDecoration(- gradient: LinearGradient(- begin: Alignment.topCenter,- end: Alignment.bottomCenter,- colors: [- Colors.black45,- Colors.transparent,- ],+ visible: !playerController.lockPanel &&+ (widget.disableAnimations+ ? playerController.showVideoController+ : true),+ child: widget.disableAnimations+ ? Container(+ height: 50,+ decoration: const BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [+ Colors.black45,+ Colors.transparent,+ ],+ ),+ ),+ )+ : SlideTransition(+ position: topOffsetAnimation,+ child: Container(+ height: 50,+ decoration: const BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [+ Colors.black45,+ Colors.transparent,+ ],+ ),+ ),+ ),),- ),- ),- ),),),@@ -358,23 +369,40 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {left: 0,right: 0,child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: bottomOffsetAnimation,- child: Container(- height: 100,- decoration: const BoxDecoration(- gradient: LinearGradient(- begin: Alignment.topCenter,- end: Alignment.bottomCenter,- colors: [- Colors.transparent,- Colors.black45,- ],+ visible: !playerController.lockPanel &&+ (widget.disableAnimations+ ? playerController.showVideoController+ : true),+ child: widget.disableAnimations+ ? Container(+ height: 100,+ decoration: const BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [+ Colors.transparent,+ Colors.black45,+ ],+ ),+ ),+ )+ : SlideTransition(+ position: bottomOffsetAnimation,+ child: Container(+ height: 100,+ decoration: const BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [+ Colors.transparent,+ Colors.black45,+ ],+ ),+ ),+ ),),- ),- ),- ),),),// 顶部进度条@@ -495,43 +523,15 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {right: 0,top: 0,bottom: 0,- child: SlideTransition(- position: leftOffsetAnimation,- child: SafeArea(- top: false,- bottom: false,- left: videoPageController.isFullscreen,- right: videoPageController.isFullscreen,- child: Column(- children: [- const Spacer(),- (playerController.lockPanel)- ? Container()- : IconButton(- icon: const Icon(- Icons.photo_camera_outlined,- color: Colors.white,- ),- onPressed: () {- _handleScreenshot();- },- ),- IconButton(- icon: Icon(- playerController.lockPanel- ? Icons.lock_outline- : Icons.lock_open,- color: Colors.white,- ),- onPressed: () {- playerController.lockPanel =- !playerController.lockPanel;- },- ),- const Spacer(),- ],- ),- ),+ child: Visibility(+ visible: widget.disableAnimations+ ? playerController.showVideoController+ : true,+ child: widget.disableAnimations+ ? leftControlWidget+ : SlideTransition(+ position: leftOffsetAnimation,+ child: leftControlWidget),),),// 自定义顶部组件@@ -540,759 +540,780 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {left: 0,right: 0,child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: topOffsetAnimation,- child: EmbeddedNativeControlArea(- requireOffset: !videoPageController.isFullscreen,- child: SafeArea(- top: false,- bottom: false,- left: videoPageController.isFullscreen,- right: videoPageController.isFullscreen,- child: MouseRegion(- cursor: (videoPageController.isFullscreen &&- !playerController.showVideoController)- ? SystemMouseCursors.none- : SystemMouseCursors.basic,- onEnter: (_) {- widget.cancelHideTimer();- },- onExit: (_) {- widget.cancelHideTimer();- widget.startHideTimer();- },- child: Row(- children: [- IconButton(- color: Colors.white,- icon: const Icon(Icons.arrow_back_rounded),- onPressed: () {- widget.onBackPressed(context);- },- ),- // 拖动条- Expanded(- child: dtb.DragToMoveArea(- child: Text(- ' ${videoPageController.title} [${videoPageController.roadList[videoPageController.currentRoad].identifier[videoPageController.currentEpisode - 1]}]',- style: TextStyle(- color: Colors.white,- fontSize: Theme.of(context)- .textTheme- .titleMedium!- .fontSize,- overflow: TextOverflow.ellipsis,- ),- ),- ),- ),- // 跳过- forwardIcon(),- if (Utils.isDesktop() &&- !videoPageController.isFullscreen)- IconButton(- onPressed: () {- if (videoPageController.isPip) {- Utils.exitDesktopPIPWindow();- } else {- Utils.enterDesktopPIPWindow();- }- videoPageController.isPip =- !videoPageController.isPip;- },- icon: const Icon(- Icons.picture_in_picture,- color: Colors.white,- ),+ visible: !playerController.lockPanel &&+ (widget.disableAnimations+ ? playerController.showVideoController+ : true),+ child: widget.disableAnimations+ ? topControlWidget+ : SlideTransition(+ position: topOffsetAnimation, child: topControlWidget),+ ),+ ),+ // 自定义播放器底部组件+ Positioned(+ bottom: 0,+ left: 0,+ right: 0,+ child: Visibility(+ visible: !playerController.lockPanel &&+ (widget.disableAnimations+ ? playerController.showVideoController+ : true),+ child: widget.disableAnimations+ ? bottomControlWidget+ : SlideTransition(+ position: bottomOffsetAnimation,+ child: bottomControlWidget),+ ),+ ),+ ],+ );+ });+ }++ Widget get bottomControlWidget {+ final svgString = danmakuOnSvg.replaceFirst(+ '00AEEC',+ Theme.of(context)+ .colorScheme+ .primary+ .toARGB32()+ .toRadixString(16)+ .substring(2));+ return Observer(+ builder: (context) {+ return SafeArea(+ top: false,+ bottom: videoPageController.isFullscreen,+ left: videoPageController.isFullscreen,+ right: videoPageController.isFullscreen,+ child: MouseRegion(+ cursor: (videoPageController.isFullscreen &&+ !playerController.showVideoController)+ ? SystemMouseCursors.none+ : SystemMouseCursors.basic,+ onEnter: (_) {+ widget.cancelHideTimer();+ },+ onExit: (_) {+ widget.cancelHideTimer();+ widget.startHideTimer();+ },+ 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(+ thumbRadius: 8,+ thumbGlowRadius: 18,+ timeLabelLocation: Utils.isTablet()+ ? TimeLabelLocation.sides+ : TimeLabelLocation.none,+ timeLabelTextStyle: const TextStyle(+ color: Colors.white,+ fontSize: 12.0,+ fontFeatures: [+ FontFeature.tabularFigures(),+ ],+ ),+ progress: playerController.currentPosition,+ buffered: playerController.buffer,+ total: playerController.duration,+ onSeek: (duration) {+ playerController.seek(duration);+ },+ onDragStart: (details) {+ widget.handleProgressBarDragStart(details);+ },+ onDragUpdate: (details) =>+ {playerController.currentPosition = details.timeStamp},+ onDragEnd: () {+ widget.handleProgressBarDragEnd();+ },+ ),+ ),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 10),+ child: Row(+ children: [+ IconButton(+ color: Colors.white,+ icon: Icon(playerController.playing+ ? Icons.pause_rounded+ : Icons.play_arrow_rounded),+ onPressed: () {+ playerController.playOrPause();+ },+ ),+ // 更换选集+ 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())+ Container(+ padding: const EdgeInsets.only(left: 10.0),+ child: Text(+ "${Utils.durationToString(playerController.currentPosition)} / ${Utils.durationToString(playerController.duration)}",+ style: const TextStyle(+ color: Colors.white,+ fontSize: 16.0,+ fontFeatures: [+ FontFeature.tabularFigures(),+ ],),- // 追番- CollectButton(- bangumiItem: videoPageController.bangumiItem,- onOpen: () {- widget.cancelHideTimer();- playerController.canHidePlayerPanel = false;- },- onClose: () {- widget.cancelHideTimer();- widget.startHideTimer();- playerController.canHidePlayerPanel = true;- },),- MenuAnchor(- consumeOutsideTap: true,- onOpen: () {- widget.cancelHideTimer();- playerController.canHidePlayerPanel = false;- },- onClose: () {- widget.cancelHideTimer();- widget.startHideTimer();- playerController.canHidePlayerPanel = true;- },- builder: (BuildContext context,- MenuController controller, Widget? child) {- return IconButton(- onPressed: () {- if (controller.isOpen) {- controller.close();- } else {- controller.open();- }- },- icon: const Icon(- Icons.more_vert,- color: Colors.white,+ ),+ 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: playerController.danmakuOn+ ? SvgPicture.string(+ svgString,+ height: 24,+ )+ : SvgPicture.asset(+ 'assets/images/danmaku_off.svg',+ height: 24,+ ),+ onPressed: () {+ widget.handleDanmaku();+ },+ tooltip: playerController.danmakuOn+ ? '关闭弹幕(d)'+ : '打开弹幕(d)',+ ),+ IconButton(+ onPressed: () {+ widget.keyboardFocus.requestFocus();+ showModalBottomSheet(+ isScrollControlled: true,+ constraints: BoxConstraints(+ maxHeight: MediaQuery.of(context)+ .size+ .height *+ 3 /+ 4,+ maxWidth: (Utils.isDesktop() ||+ Utils.isTablet())+ ? MediaQuery.of(context)+ .size+ .width *+ 9 /+ 16+ : MediaQuery.of(context)+ .size+ .width),+ clipBehavior: Clip.antiAlias,+ context: context,+ builder: (context) {+ return DanmakuSettingsSheet(+ danmakuController:+ playerController+ .danmakuController);+ });+ },+ color: Colors.white,+ icon: SvgPicture.asset(+ 'assets/images/danmaku_setting.svg',+ height: 24,+ ),+ ),+ if (isSpaceEnough) danmakuTextField,+ ],),);},- menuChildren: [- MenuItemButton(- onPressed: () {- widget.showDanmakuSwitch();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("弹幕切换"),- ),- ),- ),- MenuItemButton(- onPressed: () {- widget.showVideoInfo();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("视频详情"),- ),+ ),+ ),+ if (!Utils.isDesktop()) ...[+ IconButton(+ color: Colors.white,+ icon: playerController.danmakuOn+ ? SvgPicture.string(+ svgString,+ height: 24,+ )+ : SvgPicture.asset(+ 'assets/images/danmaku_off.svg',+ height: 24,),- ),- MenuItemButton(- onPressed: () {- bool needRestart = playerController.playing;- playerController.pause();- RemotePlay()- .castVideo(- playerController.videoUrl,- videoPageController- .currentPlugin.referer)- .whenComplete(() {- if (needRestart) {- playerController.play();- }+ onPressed: () {+ widget.handleDanmaku();+ },+ tooltip:+ playerController.danmakuOn ? '关闭弹幕(d)' : '打开弹幕(d)',+ ),+ if (playerController.danmakuOn) ...[+ IconButton(+ onPressed: () {+ showModalBottomSheet(+ isScrollControlled: true,+ constraints: BoxConstraints(+ maxHeight:+ MediaQuery.of(context).size.height *+ 3 /+ 4,+ maxWidth:+ (Utils.isDesktop() || Utils.isTablet())+ ? MediaQuery.of(context).size.width *+ 9 /+ 16+ : MediaQuery.of(context).size.width),+ clipBehavior: Clip.antiAlias,+ context: context,+ builder: (context) {+ return DanmakuSettingsSheet(+ danmakuController:+ playerController.danmakuController);});- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("远程投屏"),+ },+ color: Colors.white,+ icon: SvgPicture.asset(+ 'assets/images/danmaku_setting.svg',+ height: 24,+ ),+ ),+ Expanded(child: danmakuTextField),+ ],+ if (!playerController.danmakuOn) const Spacer(),+ ],+ // 超分辨率+ MenuAnchor(+ consumeOutsideTap: true,+ onOpen: () {+ widget.cancelHideTimer();+ playerController.canHidePlayerPanel = false;+ },+ onClose: () {+ widget.cancelHideTimer();+ widget.startHideTimer();+ playerController.canHidePlayerPanel = true;+ },+ builder: (BuildContext context, MenuController controller,+ Widget? child) {+ return TextButton(+ onPressed: () {+ if (controller.isOpen) {+ controller.close();+ } else {+ controller.open();+ }+ },+ child: const Text(+ '超分辨率',+ style: TextStyle(color: Colors.white),+ ),+ );+ },+ menuChildren: List<MenuItemButton>.generate(+ 3,+ (int index) => MenuItemButton(+ onPressed: () =>+ widget.handleSuperResolutionChange(index + 1),+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ index + 1 == 1+ ? '关闭'+ : index + 1 == 2+ ? '效率档'+ : '质量档',+ style: TextStyle(+ color: playerController.superResolutionType ==+ index + 1+ ? Theme.of(context).colorScheme.primary+ : null,),),),- MenuItemButton(- onPressed: () {- playerController.lanunchExternalPlayer();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("外部播放"),+ ),+ ),+ ),+ ),+ // 倍速播放+ MenuAnchor(+ consumeOutsideTap: true,+ onOpen: () {+ widget.cancelHideTimer();+ playerController.canHidePlayerPanel = false;+ },+ onClose: () {+ widget.cancelHideTimer();+ widget.startHideTimer();+ playerController.canHidePlayerPanel = true;+ },+ builder: (BuildContext context, MenuController controller,+ Widget? child) {+ return TextButton(+ onPressed: () {+ if (controller.isOpen) {+ controller.close();+ } else {+ controller.open();+ }+ },+ child: Text(+ playerController.playerSpeed == 1.0+ ? '倍速'+ : '${playerController.playerSpeed}x',+ style: const TextStyle(color: Colors.white),+ ),+ );+ },+ menuChildren: [+ for (final double i+ in defaultPlaySpeedList) ...<MenuItemButton>[+ MenuItemButton(+ onPressed: () async {+ await widget.setPlaybackSpeed(i);+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ '${i}x',+ style: TextStyle(+ color: i == playerController.playerSpeed+ ? Theme.of(context).colorScheme.primary+ : null,+ ),),),),- SubmenuButton(- menuChildren: [- MenuItemButton(- child: Container(- height: 48,- constraints:- BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- "当前房间: ${playerController.syncplayRoom == '' ? '未加入' : playerController.syncplayRoom}"),- ),- ),- ),- MenuItemButton(- child: Container(- height: 48,- constraints:- BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- "网络延时: ${playerController.syncplayClientRtt}ms"),- ),- ),- ),- MenuItemButton(- onPressed: () {- widget.showSyncPlayRoomCreateDialog();- },- child: Container(- height: 48,- constraints:- BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("加入房间"),- ),- ),- ),- MenuItemButton(- onPressed: () {- widget.showSyncPlayEndPointSwitchDialog();- },- child: Container(- height: 48,- constraints:- BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("切换服务器"),- ),- ),- ),- MenuItemButton(- onPressed: () async {- await playerController.exitSyncPlayRoom();- },- child: Container(- height: 48,- constraints:- BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("断开连接"),- ),+ ),+ ],+ ],+ ),+ MenuAnchor(+ consumeOutsideTap: true,+ onOpen: () {+ widget.cancelHideTimer();+ playerController.canHidePlayerPanel = false;+ },+ onClose: () {+ widget.cancelHideTimer();+ widget.startHideTimer();+ playerController.canHidePlayerPanel = true;+ },+ builder: (BuildContext context, MenuController controller,+ Widget? child) {+ return IconButton(+ onPressed: () {+ if (controller.isOpen) {+ controller.close();+ } else {+ controller.open();+ }+ },+ icon: const Icon(+ Icons.aspect_ratio_rounded,+ color: Colors.white,+ ),+ tooltip: '视频比例',+ );+ },+ menuChildren: [+ for (final entry in aspectRatioTypeMap.entries)+ MenuItemButton(+ onPressed: () =>+ playerController.aspectRatioType = entry.key,+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ entry.value,+ style: TextStyle(+ color: entry.key ==+ playerController.aspectRatioType+ ? Theme.of(context).colorScheme.primary+ : null,),),- ],- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("一起看"),- ),),),- ],- ),+ ),],),- ),+ (!videoPageController.isFullscreen &&+ !Utils.isTablet() &&+ !Utils.isDesktop())+ ? Container()+ : IconButton(+ color: Colors.white,+ icon: const Icon(Icons.menu_open_rounded),+ onPressed: () {+ videoPageController.showTabBody =+ !videoPageController.showTabBody;+ widget.openMenu();+ },+ ),+ (Utils.isTablet() &&+ videoPageController.isFullscreen &&+ MediaQuery.of(context).size.height <+ MediaQuery.of(context).size.width)+ ? Container()+ : IconButton(+ color: Colors.white,+ icon: Icon(videoPageController.isFullscreen+ ? Icons.fullscreen_exit_rounded+ : Icons.fullscreen_rounded),+ onPressed: () {+ widget.handleFullscreen();+ },+ ),+ ],),),- ),+ if (Utils.isTablet() || Utils.isDesktop())+ const SizedBox(height: 6),+ ],),),- // 自定义播放器底部组件- Positioned(- bottom: 0,- left: 0,- right: 0,- child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: bottomOffsetAnimation,- child: SafeArea(- top: false,- bottom: videoPageController.isFullscreen,- left: videoPageController.isFullscreen,- right: videoPageController.isFullscreen,- child: MouseRegion(- cursor: (videoPageController.isFullscreen &&- !playerController.showVideoController)- ? SystemMouseCursors.none- : SystemMouseCursors.basic,- onEnter: (_) {+ );+ }+ );+ }++ Widget get topControlWidget {+ return Observer(+ builder: (context) {+ return EmbeddedNativeControlArea(+ requireOffset: !videoPageController.isFullscreen,+ child: SafeArea(+ top: false,+ bottom: false,+ left: videoPageController.isFullscreen,+ right: videoPageController.isFullscreen,+ child: MouseRegion(+ cursor: (videoPageController.isFullscreen &&+ !playerController.showVideoController)+ ? SystemMouseCursors.none+ : SystemMouseCursors.basic,+ onEnter: (_) {+ widget.cancelHideTimer();+ },+ onExit: (_) {+ widget.cancelHideTimer();+ widget.startHideTimer();+ },+ child: Row(+ children: [+ IconButton(+ color: Colors.white,+ icon: const Icon(Icons.arrow_back_rounded),+ onPressed: () {+ widget.onBackPressed(context);+ },+ ),+ // 拖动条+ Expanded(+ child: dtb.DragToMoveArea(+ child: Text(+ ' ${videoPageController.title} [${videoPageController.roadList[videoPageController.currentRoad].identifier[videoPageController.currentEpisode - 1]}]',+ style: TextStyle(+ color: Colors.white,+ fontSize:+ Theme.of(context).textTheme.titleMedium!.fontSize,+ overflow: TextOverflow.ellipsis,+ ),+ ),+ ),+ ),+ // 跳过+ forwardIcon(),+ if (Utils.isDesktop() && !videoPageController.isFullscreen)+ IconButton(+ onPressed: () {+ if (videoPageController.isPip) {+ Utils.exitDesktopPIPWindow();+ } else {+ Utils.enterDesktopPIPWindow();+ }+ videoPageController.isPip = !videoPageController.isPip;+ },+ icon: const Icon(+ Icons.picture_in_picture,+ color: Colors.white,+ ),+ ),+ // 追番+ CollectButton(+ bangumiItem: videoPageController.bangumiItem,+ onOpen: () {widget.cancelHideTimer();+ playerController.canHidePlayerPanel = false;},- onExit: (_) {+ onClose: () {widget.cancelHideTimer();widget.startHideTimer();+ playerController.canHidePlayerPanel = true;},- 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(),- ],+ ),+ MenuAnchor(+ consumeOutsideTap: true,+ onOpen: () {+ widget.cancelHideTimer();+ playerController.canHidePlayerPanel = false;+ },+ onClose: () {+ widget.cancelHideTimer();+ widget.startHideTimer();+ playerController.canHidePlayerPanel = true;+ },+ builder: (BuildContext context, MenuController controller,+ Widget? child) {+ return IconButton(+ onPressed: () {+ if (controller.isOpen) {+ controller.close();+ } else {+ controller.open();+ }+ },+ icon: const Icon(+ Icons.more_vert,+ color: Colors.white,+ ),+ );+ },+ menuChildren: [+ MenuItemButton(+ onPressed: () {+ widget.showDanmakuSwitch();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("弹幕切换"),+ ),+ ),+ ),+ MenuItemButton(+ onPressed: () {+ widget.showVideoInfo();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("视频详情"),+ ),+ ),+ ),+ MenuItemButton(+ onPressed: () {+ bool needRestart = playerController.playing;+ playerController.pause();+ RemotePlay()+ .castVideo(playerController.videoUrl,+ videoPageController.currentPlugin.referer)+ .whenComplete(() {+ if (needRestart) {+ playerController.play();+ }+ });+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("远程投屏"),+ ),+ ),+ ),+ MenuItemButton(+ onPressed: () {+ playerController.lanunchExternalPlayer();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("外部播放"),+ ),+ ),+ ),+ SubmenuButton(+ menuChildren: [+ MenuItemButton(+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ "当前房间: ${playerController.syncplayRoom == '' ? '未加入' : playerController.syncplayRoom}"),),),),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 10),- child: ProgressBar(- thumbRadius: 8,- thumbGlowRadius: 18,- timeLabelLocation: Utils.isTablet()- ? TimeLabelLocation.sides- : TimeLabelLocation.none,- timeLabelTextStyle: const TextStyle(- color: Colors.white,- fontSize: 12.0,- fontFeatures: [- FontFeature.tabularFigures(),- ],+ MenuItemButton(+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ "网络延时: ${playerController.syncplayClientRtt}ms"),+ ),),- progress: playerController.currentPosition,- buffered: playerController.buffer,- total: playerController.duration,- onSeek: (duration) {- playerController.seek(duration);- },- onDragStart: (details) {- widget.handleProgressBarDragStart(details);- },- onDragUpdate: (details) => {- playerController.currentPosition =- details.timeStamp- },- onDragEnd: () {- widget.handleProgressBarDragEnd();- },),- ),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 10),- child: Row(- children: [- IconButton(- color: Colors.white,- icon: Icon(playerController.playing- ? Icons.pause_rounded- : Icons.play_arrow_rounded),- onPressed: () {- playerController.playOrPause();- },- ),- // 更换选集- 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())- Container(- padding: const EdgeInsets.only(left: 10.0),- child: Text(- "${Utils.durationToString(playerController.currentPosition)} / ${Utils.durationToString(playerController.duration)}",- style: const TextStyle(- color: Colors.white,- 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: playerController.danmakuOn- ? SvgPicture.string(- svgString,- height: 24,- )- : SvgPicture.asset(- 'assets/images/danmaku_off.svg',- height: 24,- ),- onPressed: () {- widget.handleDanmaku();- },- tooltip:- playerController.danmakuOn- ? '关闭弹幕(d)'- : '打开弹幕(d)',- ),- IconButton(- onPressed: () {- widget.keyboardFocus- .requestFocus();- showModalBottomSheet(- isScrollControlled: true,- constraints: BoxConstraints(- maxHeight:- MediaQuery.of(context)- .size- .height *- 3 /- 4,- maxWidth: (Utils- .isDesktop() ||- Utils- .isTablet())- ? MediaQuery.of(- context)- .size- .width *- 9 /- 16- : MediaQuery.of(- context)- .size- .width),- clipBehavior:- Clip.antiAlias,- context: context,- builder: (context) {- return DanmakuSettingsSheet(- danmakuController:- playerController- .danmakuController);- });- },- color: Colors.white,- icon: SvgPicture.asset(- 'assets/images/danmaku_setting.svg',- height: 24,- ),- ),- if (isSpaceEnough) danmakuTextField,- ],- ),- );- },- ),- ),- if (!Utils.isDesktop()) ...[- IconButton(- color: Colors.white,- icon: playerController.danmakuOn- ? SvgPicture.string(- svgString,- height: 24,- )- : SvgPicture.asset(- 'assets/images/danmaku_off.svg',- height: 24,- ),- onPressed: () {- widget.handleDanmaku();- },- tooltip: playerController.danmakuOn- ? '关闭弹幕(d)'- : '打开弹幕(d)',- ),- if (playerController.danmakuOn) ...[- IconButton(- onPressed: () {- showModalBottomSheet(- isScrollControlled: true,- constraints: BoxConstraints(- maxHeight: MediaQuery.of(context)- .size- .height *- 3 /- 4,- maxWidth: (Utils.isDesktop() ||- Utils.isTablet())- ? MediaQuery.of(context)- .size- .width *- 9 /- 16- : MediaQuery.of(context)- .size- .width),- clipBehavior: Clip.antiAlias,- context: context,- builder: (context) {- return DanmakuSettingsSheet(- danmakuController:- playerController- .danmakuController);- });- },- color: Colors.white,- icon: SvgPicture.asset(- 'assets/images/danmaku_setting.svg',- height: 24,- ),- ),- Expanded(child: danmakuTextField),- ],- if (!playerController.danmakuOn) const Spacer(),- ],- // 超分辨率- MenuAnchor(- consumeOutsideTap: true,- onOpen: () {- widget.cancelHideTimer();- playerController.canHidePlayerPanel = false;- },- onClose: () {- widget.cancelHideTimer();- widget.startHideTimer();- playerController.canHidePlayerPanel = true;- },- builder: (BuildContext context,- MenuController controller, Widget? child) {- return TextButton(- onPressed: () {- if (controller.isOpen) {- controller.close();- } else {- controller.open();- }- },- child: const Text(- '超分辨率',- style: TextStyle(color: Colors.white),- ),- );- },- menuChildren: List<MenuItemButton>.generate(- 3,- (int index) => MenuItemButton(- onPressed: () =>- widget.handleSuperResolutionChange(index + 1),- child: Container(- height: 48,- constraints:- BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- index + 1 == 1- ? '关闭'- : index + 1 == 2- ? '效率档'- : '质量档',- style: TextStyle(- color: playerController- .superResolutionType ==- index + 1- ? Theme.of(context)- .colorScheme- .primary- : null,- ),- ),- ),- ),- ),- ),+ MenuItemButton(+ onPressed: () {+ widget.showSyncPlayRoomCreateDialog();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("加入房间"),),- // 倍速播放- MenuAnchor(- consumeOutsideTap: true,- onOpen: () {- widget.cancelHideTimer();- playerController.canHidePlayerPanel = false;- },- onClose: () {- widget.cancelHideTimer();- widget.startHideTimer();- playerController.canHidePlayerPanel = true;- },- builder: (BuildContext context,- MenuController controller, Widget? child) {- return TextButton(- onPressed: () {- if (controller.isOpen) {- controller.close();- } else {- controller.open();- }- },- child: Text(- playerController.playerSpeed == 1.0- ? '倍速'- : '${playerController.playerSpeed}x',- style:- const TextStyle(color: Colors.white),- ),- );- },- menuChildren: [- for (final double i- in defaultPlaySpeedList) ...<MenuItemButton>[- MenuItemButton(- onPressed: () async {- await widget.setPlaybackSpeed(i);- },- child: Container(- height: 48,- constraints:- BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- '${i}x',- style: TextStyle(- color: i ==- playerController- .playerSpeed- ? Theme.of(context)- .colorScheme- .primary- : null,- ),- ),- ),- ),- ),- ],- ],+ ),+ ),+ MenuItemButton(+ onPressed: () {+ widget.showSyncPlayEndPointSwitchDialog();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("切换服务器"),),- MenuAnchor(- consumeOutsideTap: true,- onOpen: () {- widget.cancelHideTimer();- playerController.canHidePlayerPanel = false;- },- onClose: () {- widget.cancelHideTimer();- widget.startHideTimer();- playerController.canHidePlayerPanel = true;- },- builder: (BuildContext context,- MenuController controller, Widget? child) {- return IconButton(- onPressed: () {- if (controller.isOpen) {- controller.close();- } else {- controller.open();- }- },- icon: const Icon(- Icons.aspect_ratio_rounded,- color: Colors.white,- ),- tooltip: '视频比例',- );- },- menuChildren: [- for (final entry- in aspectRatioTypeMap.entries)- MenuItemButton(- onPressed: () => playerController- .aspectRatioType = entry.key,- child: Container(- height: 48,- constraints:- BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- entry.value,- style: TextStyle(- color: entry.key ==- playerController- .aspectRatioType- ? Theme.of(context)- .colorScheme- .primary- : null,- ),- ),- ),- ),- ),- ],+ ),+ ),+ MenuItemButton(+ onPressed: () async {+ await playerController.exitSyncPlayRoom();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("断开连接"),),- (!videoPageController.isFullscreen &&- !Utils.isTablet() &&- !Utils.isDesktop())- ? Container()- : IconButton(- color: Colors.white,- icon: const Icon(Icons.menu_open_rounded),- onPressed: () {- videoPageController.showTabBody =- !videoPageController.showTabBody;- widget.openMenu();- },- ),- (Utils.isTablet() &&- videoPageController.isFullscreen &&- MediaQuery.of(context).size.height <- MediaQuery.of(context).size.width)- ? Container()- : IconButton(- color: Colors.white,- icon: Icon(- videoPageController.isFullscreen- ? Icons.fullscreen_exit_rounded- : Icons.fullscreen_rounded),- onPressed: () {- widget.handleFullscreen();- },- ),- ],+ ),+ ),+ ],+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("一起看"),),),- if (Utils.isTablet() || Utils.isDesktop())- const SizedBox(height: 6),- ],- ),+ ),+ ],),- ),+ ],),),),- ],- );- });+ );+ }+ );+ }++ Widget get leftControlWidget {+ return Observer(+ builder: (context) {+ return SafeArea(+ top: false,+ bottom: false,+ left: videoPageController.isFullscreen,+ right: videoPageController.isFullscreen,+ child: Column(+ children: [+ const Spacer(),+ (playerController.lockPanel)+ ? Container()+ : IconButton(+ icon: const Icon(+ Icons.photo_camera_outlined,+ color: Colors.white,+ ),+ onPressed: () {+ _handleScreenshot();+ },+ ),+ IconButton(+ icon: Icon(+ playerController.lockPanel ? Icons.lock_outline : Icons.lock_open,+ color: Colors.white,+ ),+ onPressed: () {+ playerController.lockPanel = !playerController.lockPanel;+ },+ ),+ const Spacer(),+ ],+ ),+ );+ }+ );}}diff --git a/lib/pages/player/smallest_player_item_panel.dart b/lib/pages/player/smallest_player_item_panel.dartindex 0be075bf..74375c1b 100644--- a/lib/pages/player/smallest_player_item_panel.dart+++ b/lib/pages/player/smallest_player_item_panel.dart@@ -36,6 +36,7 @@ class SmallestPlayerItemPanel extends StatefulWidget {required this.showVideoInfo,required this.showSyncPlayRoomCreateDialog,required this.showSyncPlayEndPointSwitchDialog,+ this.disableAnimations = false,});final void Function(BuildContext) onBackPressed;@@ -54,6 +55,7 @@ class SmallestPlayerItemPanel extends StatefulWidget {final void Function() showVideoInfo;final void Function() showSyncPlayRoomCreateDialog;final void Function() showSyncPlayEndPointSwitchDialog;+ final bool disableAnimations;@overrideState<SmallestPlayerItemPanel> createState() =>@@ -165,14 +167,6 @@ class _SmallestPlayerItemPanelState extends State<SmallestPlayerItemPanel> {@overrideWidget build(BuildContext context) {- final svgString = danmakuOnSvg.replaceFirst(- '00AEEC',- Theme.of(context)- .colorScheme- .primary- .toARGB32()- .toRadixString(16)- .substring(2));return Observer(builder: (context) {return Stack(alignment: Alignment.center,@@ -347,456 +341,466 @@ class _SmallestPlayerItemPanelState extends State<SmallestPlayerItemPanel> {left: 0,right: 0,child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: topOffsetAnimation,- child: EmbeddedNativeControlArea(- child: Row(- children: [- IconButton(- color: Colors.white,- icon: const Icon(Icons.arrow_back_rounded),- onPressed: () {- widget.onBackPressed(context);- },- ),- // 拖动条- const Expanded(- child: dtb.DragToMoveArea(child: SizedBox(height: 40)),- ),- // 跳过- forwardIcon(),- if (Utils.isDesktop())- IconButton(- onPressed: () {- if (videoPageController.isPip) {- Utils.exitDesktopPIPWindow();- } else {- Utils.enterDesktopPIPWindow();- }- videoPageController.isPip =- !videoPageController.isPip;- },- icon: const Icon(Icons.picture_in_picture,- color: Colors.white)),- // 弹幕开关- IconButton(- color: Colors.white,- icon: playerController.danmakuOn- ? SvgPicture.string(- svgString,- height: 24,- )- : SvgPicture.asset(- 'assets/images/danmaku_off.svg',- height: 24,- ),- onPressed: () {- widget.handleDanmaku();- },- tooltip: playerController.danmakuOn ? '关闭弹幕' : '打开弹幕',- ),- // 追番- CollectButton(- bangumiItem: videoPageController.bangumiItem,- onOpen: () {- widget.cancelHideTimer();- playerController.canHidePlayerPanel = false;- },- onClose: () {- widget.cancelHideTimer();- widget.startHideTimer();- playerController.canHidePlayerPanel = true;- },+ visible: !playerController.lockPanel &&+ (widget.disableAnimations+ ? playerController.showVideoController+ : true),+ child: widget.disableAnimations+ ? topControlWidget+ : SlideTransition(+ position: topOffsetAnimation, child: topControlWidget),+ ),+ ),+ // 自定义播放器底部组件+ Positioned(+ bottom: 0,+ left: 0,+ right: 0,+ child: Visibility(+ visible: !playerController.lockPanel &&+ (widget.disableAnimations+ ? playerController.showVideoController+ : true),+ child: widget.disableAnimations+ ? bottomControlWidget+ : SlideTransition(+ position: bottomOffsetAnimation,+ child: bottomControlWidget),+ ),+ ),+ ],+ );+ });+ }++ Widget get bottomControlWidget {+ return Observer(builder: (context) {+ return Row(+ children: [+ IconButton(+ color: Colors.white,+ icon: Icon(playerController.playing+ ? Icons.pause_rounded+ : Icons.play_arrow_rounded),+ onPressed: () {+ playerController.playOrPause();+ },+ ),+ Expanded(+ child: ProgressBar(+ thumbRadius: 8,+ thumbGlowRadius: 18,+ timeLabelLocation: TimeLabelLocation.none,+ progress: playerController.currentPosition,+ buffered: playerController.buffer,+ total: playerController.duration,+ onSeek: (duration) {+ playerController.seek(duration);+ },+ onDragStart: (details) {+ widget.handleProgressBarDragStart(details);+ },+ onDragUpdate: (details) =>+ {playerController.currentPosition = details.timeStamp},+ onDragEnd: () {+ widget.handleProgressBarDragEnd();+ },+ ),+ ),+ Text(+ " ${Utils.durationToString(playerController.currentPosition)} / ${Utils.durationToString(playerController.duration)}",+ style: const TextStyle(+ color: Colors.white,+ fontSize: 12.0,+ fontFeatures: [+ FontFeature.tabularFigures(),+ ],+ ),+ ),+ (!videoPageController.isPip)+ ? IconButton(+ color: Colors.white,+ icon: Icon(videoPageController.isFullscreen+ ? Icons.fullscreen_exit_rounded+ : Icons.fullscreen_rounded),+ onPressed: () {+ widget.handleFullscreen();+ },+ )+ : const Text(' '),+ ],+ );+ });+ }++ Widget get topControlWidget {+ final svgString = danmakuOnSvg.replaceFirst(+ '00AEEC',+ Theme.of(context)+ .colorScheme+ .primary+ .toARGB32()+ .toRadixString(16)+ .substring(2));+ return Observer(builder: (context) {+ return EmbeddedNativeControlArea(+ child: Row(+ children: [+ IconButton(+ color: Colors.white,+ icon: const Icon(Icons.arrow_back_rounded),+ onPressed: () {+ widget.onBackPressed(context);+ },+ ),+ // 拖动条+ const Expanded(+ child: dtb.DragToMoveArea(child: SizedBox(height: 40)),+ ),+ // 跳过+ forwardIcon(),+ if (Utils.isDesktop())+ IconButton(+ onPressed: () {+ if (videoPageController.isPip) {+ Utils.exitDesktopPIPWindow();+ } else {+ Utils.enterDesktopPIPWindow();+ }+ videoPageController.isPip = !videoPageController.isPip;+ },+ icon: const Icon(Icons.picture_in_picture,+ color: Colors.white)),+ // 弹幕开关+ IconButton(+ color: Colors.white,+ icon: playerController.danmakuOn+ ? SvgPicture.string(+ svgString,+ height: 24,+ )+ : SvgPicture.asset(+ 'assets/images/danmaku_off.svg',+ height: 24,+ ),+ onPressed: () {+ widget.handleDanmaku();+ },+ tooltip: playerController.danmakuOn ? '关闭弹幕' : '打开弹幕',+ ),+ // 追番+ CollectButton(+ bangumiItem: videoPageController.bangumiItem,+ onOpen: () {+ widget.cancelHideTimer();+ playerController.canHidePlayerPanel = false;+ },+ onClose: () {+ widget.cancelHideTimer();+ widget.startHideTimer();+ playerController.canHidePlayerPanel = true;+ },+ ),+ MenuAnchor(+ consumeOutsideTap: true,+ onOpen: () {+ widget.cancelHideTimer();+ playerController.canHidePlayerPanel = false;+ },+ onClose: () {+ widget.cancelHideTimer();+ widget.startHideTimer();+ playerController.canHidePlayerPanel = true;+ },+ builder: (BuildContext context, MenuController controller,+ Widget? child) {+ return IconButton(+ onPressed: () {+ if (controller.isOpen) {+ controller.close();+ } else {+ controller.open();+ }+ },+ icon: const Icon(+ Icons.more_vert,+ color: Colors.white,+ ),+ );+ },+ menuChildren: [+ SubmenuButton(+ menuChildren: List<MenuItemButton>.generate(+ 3,+ (int index) => MenuItemButton(+ onPressed: () =>+ playerController.aspectRatioType = index + 1,+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ index + 1 == 1+ ? '自动'+ : index + 1 == 2+ ? '裁切填充'+ : '拉伸填充',+ style: TextStyle(+ color: index + 1 ==+ playerController.aspectRatioType+ ? Theme.of(context).colorScheme.primary+ : null),+ ),+ ),),- MenuAnchor(- consumeOutsideTap: true,- onOpen: () {- widget.cancelHideTimer();- playerController.canHidePlayerPanel = false;- },- onClose: () {- widget.cancelHideTimer();- widget.startHideTimer();- playerController.canHidePlayerPanel = true;- },- builder: (BuildContext context,- MenuController controller, Widget? child) {- return IconButton(- onPressed: () {- if (controller.isOpen) {- controller.close();- } else {- controller.open();- }- },- icon: const Icon(- Icons.more_vert,- color: Colors.white,- ),- );+ ),+ ),+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("视频比例"),+ ),+ ),+ ),+ SubmenuButton(+ menuChildren: [+ for (final double i+ in defaultPlaySpeedList) ...<MenuItemButton>[+ MenuItemButton(+ onPressed: () async {+ await widget.setPlaybackSpeed(i);},- menuChildren: [- SubmenuButton(- menuChildren: List<MenuItemButton>.generate(- 3,- (int index) => MenuItemButton(- onPressed: () => playerController- .aspectRatioType = index + 1,- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- index + 1 == 1- ? '自动'- : index + 1 == 2- ? '裁切填充'- : '拉伸填充',- style: TextStyle(- color: index + 1 ==- playerController- .aspectRatioType- ? Theme.of(context)- .colorScheme- .primary- : null),- ),- ),- ),- ),- ),- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("视频比例"),- ),- ),- ),- SubmenuButton(- menuChildren: [- for (final double i- in defaultPlaySpeedList) ...<MenuItemButton>[- MenuItemButton(- onPressed: () async {- await widget.setPlaybackSpeed(i);- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- '${i}x',- style: TextStyle(- color: i ==- playerController.playerSpeed- ? Theme.of(context)- .colorScheme- .primary- : null),- ),- ),- ),- ),- ],- ],- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("倍速"),- ),- ),- ),- SubmenuButton(- menuChildren: List<MenuItemButton>.generate(- 3,- (int index) => MenuItemButton(- onPressed: () =>- widget.handleSuperResolutionChange(index + 1),- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- index + 1 == 1- ? '关闭'- : index + 1 == 2- ? '效率档'- : '质量档',- style: TextStyle(- color: playerController- .superResolutionType ==- index + 1- ? Theme.of(context)- .colorScheme- .primary- : null,- ),- ),- ),- ),- ),- ),- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("超分辨率"),- ),+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ '${i}x',+ style: TextStyle(+ color: i == playerController.playerSpeed+ ? Theme.of(context).colorScheme.primary+ : null),),),- SubmenuButton(- menuChildren: [- MenuItemButton(- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- "当前房间: ${playerController.syncplayRoom == '' ? '未加入' : playerController.syncplayRoom}"),- ),- ),- ),- MenuItemButton(- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text(- "网络延时: ${playerController.syncplayClientRtt}ms"),- ),- ),- ),- MenuItemButton(- onPressed: () {- widget.showSyncPlayRoomCreateDialog();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("加入房间"),- ),- ),- ),- MenuItemButton(- onPressed: () {- widget.showSyncPlayEndPointSwitchDialog();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("切换服务器"),- ),- ),- ),- MenuItemButton(- onPressed: () async {- await playerController.exitSyncPlayRoom();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("断开连接"),- ),- ),- ),- ],- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("一起看"),- ),- ),- ),- MenuItemButton(- onPressed: () {- widget.showDanmakuSwitch();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("弹幕切换"),- ),- ),- ),- MenuItemButton(- onPressed: () {- showModalBottomSheet(- isScrollControlled: true,- constraints: BoxConstraints(- maxHeight:- MediaQuery.of(context).size.height *- 3 /- 4,- maxWidth: (Utils.isDesktop() ||- Utils.isTablet())- ? MediaQuery.of(context).size.width *- 9 /- 16- : MediaQuery.of(context).size.width),- clipBehavior: Clip.antiAlias,- context: context,- builder: (context) {- return DanmakuSettingsSheet(- danmakuController:- playerController.danmakuController);- },- );- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("弹幕设置"),- ),- ),- ),- MenuItemButton(- onPressed: () {- widget.showVideoInfo();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("视频详情"),- ),- ),- ),- MenuItemButton(- onPressed: () {- bool needRestart = playerController.playing;- playerController.pause();- RemotePlay()- .castVideo(playerController.videoUrl,- videoPageController.currentPlugin.referer)- .whenComplete(() {- if (needRestart) {- playerController.play();- }- });- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("远程投屏"),- ),- ),- ),- MenuItemButton(- onPressed: () {- playerController.lanunchExternalPlayer();- },- child: Container(- height: 48,- constraints: BoxConstraints(minWidth: 112),- child: Align(- alignment: Alignment.centerLeft,- child: Text("外部播放"),- ),+ ),+ ),+ ],+ ],+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("倍速"),+ ),+ ),+ ),+ SubmenuButton(+ menuChildren: List<MenuItemButton>.generate(+ 3,+ (int index) => MenuItemButton(+ onPressed: () =>+ widget.handleSuperResolutionChange(index + 1),+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ index + 1 == 1+ ? '关闭'+ : index + 1 == 2+ ? '效率档'+ : '质量档',+ style: TextStyle(+ color: playerController.superResolutionType ==+ index + 1+ ? Theme.of(context).colorScheme.primary+ : null,),),- ],+ ),),- ],+ ),+ ),+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("超分辨率"),+ ),),),- ),- ),- ),- // 自定义播放器底部组件- Positioned(- bottom: 0,- left: 0,- right: 0,- child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: bottomOffsetAnimation,- child: Row(- children: [- IconButton(- color: Colors.white,- icon: Icon(playerController.playing- ? Icons.pause_rounded- : Icons.play_arrow_rounded),+ SubmenuButton(+ menuChildren: [+ MenuItemButton(+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ "当前房间: ${playerController.syncplayRoom == '' ? '未加入' : playerController.syncplayRoom}"),+ ),+ ),+ ),+ MenuItemButton(+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ "网络延时: ${playerController.syncplayClientRtt}ms"),+ ),+ ),+ ),+ MenuItemButton(onPressed: () {- playerController.playOrPause();+ widget.showSyncPlayRoomCreateDialog();},+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("加入房间"),+ ),+ ),),- Expanded(- child: ProgressBar(- thumbRadius: 8,- thumbGlowRadius: 18,- timeLabelLocation: TimeLabelLocation.none,- progress: playerController.currentPosition,- buffered: playerController.buffer,- total: playerController.duration,- onSeek: (duration) {- playerController.seek(duration);- },- onDragStart: (details) {- widget.handleProgressBarDragStart(details);- },- onDragUpdate: (details) => {- playerController.currentPosition = details.timeStamp- },- onDragEnd: () {- widget.handleProgressBarDragEnd();- },+ MenuItemButton(+ onPressed: () {+ widget.showSyncPlayEndPointSwitchDialog();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("切换服务器"),+ ),),),- Text(- " ${Utils.durationToString(playerController.currentPosition)} / ${Utils.durationToString(playerController.duration)}",- style: const TextStyle(- color: Colors.white,- fontSize: 12.0,- fontFeatures: [- FontFeature.tabularFigures(),- ],+ MenuItemButton(+ onPressed: () async {+ await playerController.exitSyncPlayRoom();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("断开连接"),+ ),),),- (!videoPageController.isPip)- ? IconButton(- color: Colors.white,- icon: Icon(videoPageController.isFullscreen- ? Icons.fullscreen_exit_rounded- : Icons.fullscreen_rounded),- onPressed: () {- widget.handleFullscreen();- },- )- : const Text(' '),],+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("一起看"),+ ),+ ),),- ),+ MenuItemButton(+ onPressed: () {+ widget.showDanmakuSwitch();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("弹幕切换"),+ ),+ ),+ ),+ MenuItemButton(+ onPressed: () {+ showModalBottomSheet(+ isScrollControlled: true,+ constraints: BoxConstraints(+ maxHeight: MediaQuery.of(context).size.height * 3 / 4,+ maxWidth: (Utils.isDesktop() || Utils.isTablet())+ ? MediaQuery.of(context).size.width * 9 / 16+ : MediaQuery.of(context).size.width),+ clipBehavior: Clip.antiAlias,+ context: context,+ builder: (context) {+ return DanmakuSettingsSheet(+ danmakuController:+ playerController.danmakuController);+ },+ );+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("弹幕设置"),+ ),+ ),+ ),+ MenuItemButton(+ onPressed: () {+ widget.showVideoInfo();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("视频详情"),+ ),+ ),+ ),+ MenuItemButton(+ onPressed: () {+ bool needRestart = playerController.playing;+ playerController.pause();+ RemotePlay()+ .castVideo(playerController.videoUrl,+ videoPageController.currentPlugin.referer)+ .whenComplete(() {+ if (needRestart) {+ playerController.play();+ }+ });+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("远程投屏"),+ ),+ ),+ ),+ MenuItemButton(+ onPressed: () {+ playerController.lanunchExternalPlayer();+ },+ child: Container(+ height: 48,+ constraints: BoxConstraints(minWidth: 112),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text("外部播放"),+ ),+ ),+ ),+ ],),- ),- ],+ ],+ ),);});}