基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
fix player blank screen
Prediditf243dfe9a8cc
diff --git a/lib/pages/player/player_item_panel.dart b/lib/pages/player/player_item_panel.dartindex da50cc0e..8fde0218 100644--- a/lib/pages/player/player_item_panel.dart+++ b/lib/pages/player/player_item_panel.dart@@ -290,523 +290,519 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {@overrideWidget build(BuildContext context) {- return Expanded(- child: Observer(builder: (context) {- return Stack(- alignment: Alignment.center,- children: [- //顶部渐变区域- AnimatedPositioned(- duration: const Duration(seconds: 1),- top: 0,- left: 0,- right: 0,- child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: playerController.topOffsetAnimation,- child: Container(- height: 50,- decoration: BoxDecoration(- gradient: LinearGradient(- begin: Alignment.topCenter,- end: Alignment.bottomCenter,- colors: [- Colors.black.withOpacity(0.9),- Colors.transparent,- ],- ),+ return Observer(builder: (context) {+ return Stack(+ alignment: Alignment.center,+ children: [+ //顶部渐变区域+ AnimatedPositioned(+ duration: const Duration(seconds: 1),+ top: 0,+ left: 0,+ right: 0,+ child: Visibility(+ visible: !playerController.lockPanel,+ child: SlideTransition(+ position: playerController.topOffsetAnimation,+ child: Container(+ height: 50,+ decoration: BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [+ Colors.black.withOpacity(0.9),+ Colors.transparent,+ ],),),),),),+ ),- //底部渐变区域- AnimatedPositioned(- duration: const Duration(seconds: 1),- bottom: 0,- left: 0,- right: 0,- child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: playerController.bottomOffsetAnimation,- child: Container(- height: 50,- decoration: BoxDecoration(- gradient: LinearGradient(- begin: Alignment.topCenter,- end: Alignment.bottomCenter,- colors: [- Colors.transparent,- Colors.black.withOpacity(0.9),- ],- ),+ //底部渐变区域+ AnimatedPositioned(+ duration: const Duration(seconds: 1),+ bottom: 0,+ left: 0,+ right: 0,+ child: Visibility(+ visible: !playerController.lockPanel,+ child: SlideTransition(+ position: playerController.bottomOffsetAnimation,+ child: Container(+ height: 50,+ decoration: BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [+ Colors.transparent,+ Colors.black.withOpacity(0.9),+ ],),),),),),- // 顶部进度条- Positioned(- top: 25,- child: playerController.showSeekTime- ? 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), // 圆角+ ),+ // 顶部进度条+ Positioned(+ top: 25,+ child: playerController.showSeekTime+ ? 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.playerPosition) >+ 0+ ? '快进 ${playerController.currentPosition.inSeconds - playerController.playerPosition.inSeconds} 秒'+ : '快退 ${playerController.playerPosition.inSeconds - playerController.currentPosition.inSeconds} 秒',+ style: const TextStyle(+ color: Colors.white,),- child: Text(- playerController.currentPosition.compareTo(- playerController- .playerPosition) >- 0- ? '快进 ${playerController.currentPosition.inSeconds - playerController.playerPosition.inSeconds} 秒'- : '快退 ${playerController.playerPosition.inSeconds - playerController.currentPosition.inSeconds} 秒',- style: const TextStyle(- color: Colors.white,+ ),+ ),+ ],+ )+ : Container()),+ // 顶部播放速度条+ Positioned(+ top: 25,+ child: playerController.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: playerController.showPlaySpeed- ? Wrap(- alignment: WrapAlignment.center,- children: <Widget>[- Container(+ ),+ ],+ )+ : Container()),+ // 亮度条+ Positioned(+ top: 25,+ child: playerController.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: const Row(+ child: Row(children: <Widget>[- Icon(Icons.fast_forward, color: Colors.white),+ const Icon(Icons.brightness_7,+ color: Colors.white),Text(- ' 倍速播放',- style: TextStyle(+ ' ${(playerController.brightness * 100).toInt()} %',+ style: const TextStyle(color: Colors.white,),),],+ )),+ ],+ )+ : Container()),+ // 音量条+ Positioned(+ top: 25,+ child: playerController.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), // 圆角),- ),- ],- )- : Container()),- // 亮度条- Positioned(- top: 25,- child: playerController.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: playerController.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.toInt()}%',- style: const TextStyle(- color: Colors.white,- ),+ child: Row(+ children: <Widget>[+ const Icon(Icons.volume_down,+ color: Colors.white),+ Text(+ ' ${playerController.volume.toInt()}%',+ style: const TextStyle(+ color: Colors.white,),- ],- )),- ],- )- : Container()),- // 右侧锁定按钮- (Utils.isDesktop() || !videoPageController.isFullscreen)- ? Container()- : Positioned(- right: 0,- top: 0,- bottom: 0,- child: SlideTransition(- position: playerController.leftOffsetAnimation,- child: Column(children: [- const Spacer(),- (playerController.lockPanel)- ? Container()- : IconButton(- icon: const Icon(- Icons.photo_camera_outlined,- color: Colors.white,),- onPressed: () {- _handleScreenshot();- },+ ],+ )),+ ],+ )+ : Container()),+ // 右侧锁定按钮+ (Utils.isDesktop() || !videoPageController.isFullscreen)+ ? Container()+ : Positioned(+ right: 0,+ top: 0,+ bottom: 0,+ child: SlideTransition(+ position: playerController.leftOffsetAnimation,+ child: Column(children: [+ const Spacer(),+ (playerController.lockPanel)+ ? Container()+ : IconButton(+ icon: const Icon(+ Icons.photo_camera_outlined,+ color: Colors.white,),- IconButton(- icon: Icon(- playerController.lockPanel- ? Icons.lock_outline- : Icons.lock_open,- color: Colors.white,- ),- onPressed: () {- playerController.lockPanel =- !playerController.lockPanel;- },- ),- const Spacer(),- ]),- ),- ),- // 自定义顶部组件- Positioned(- top: 0,- left: 0,- right: 0,- child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: playerController.topOffsetAnimation,- child: Row(- children: [+ onPressed: () {+ _handleScreenshot();+ },+ ),IconButton(- color: Colors.white,- icon: const Icon(Icons.arrow_back),+ icon: Icon(+ playerController.lockPanel+ ? Icons.lock_outline+ : Icons.lock_open,+ color: Colors.white,+ ),onPressed: () {- widget.onBackPressed(context);+ playerController.lockPanel =+ !playerController.lockPanel;},),- (videoPageController.isFullscreen || Utils.isDesktop())- ? Text(- ' ${videoPageController.title} [${videoPageController.roadList[videoPageController.currentRoad].identifier[videoPageController.currentEpisode - 1]}]',- style: TextStyle(- color: Colors.white,- fontSize: Theme.of(context)- .textTheme- .titleMedium!- .fontSize),- )- : Container(),- // 拖动条- const Expanded(- child: dtb.DragToMoveArea(child: SizedBox(height: 40)),- ),- PopupMenuButton(- tooltip: '',- child: Text(- playerController.aspectRatioType == 1- ? 'AUTO'- : playerController.aspectRatioType == 2- ? 'COVER'- : 'FILL',- style: const TextStyle(+ const Spacer(),+ ]),+ ),+ ),+ // 自定义顶部组件+ Positioned(+ top: 0,+ left: 0,+ right: 0,+ child: Visibility(+ visible: !playerController.lockPanel,+ child: SlideTransition(+ position: playerController.topOffsetAnimation,+ child: Row(+ children: [+ IconButton(+ color: Colors.white,+ icon: const Icon(Icons.arrow_back),+ onPressed: () {+ widget.onBackPressed(context);+ },+ ),+ (videoPageController.isFullscreen || Utils.isDesktop())+ ? Text(+ ' ${videoPageController.title} [${videoPageController.roadList[videoPageController.currentRoad].identifier[videoPageController.currentEpisode - 1]}]',+ style: TextStyle(color: Colors.white,- fontSize: 12,- fontWeight: FontWeight.bold)),- itemBuilder: (context) {- return const [- PopupMenuItem(- value: 1,- child: Row(- mainAxisSize: MainAxisSize.min,- children: [Text("AUTO")],- ),+ fontSize: Theme.of(context)+ .textTheme+ .titleMedium!+ .fontSize),+ )+ : Container(),+ // 拖动条+ const Expanded(+ child: dtb.DragToMoveArea(child: SizedBox(height: 40)),+ ),+ PopupMenuButton(+ tooltip: '',+ child: Text(+ playerController.aspectRatioType == 1+ ? 'AUTO'+ : playerController.aspectRatioType == 2+ ? 'COVER'+ : 'FILL',+ style: const TextStyle(+ color: Colors.white,+ fontSize: 12,+ fontWeight: FontWeight.bold)),+ itemBuilder: (context) {+ return const [+ PopupMenuItem(+ value: 1,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [Text("AUTO")],),- PopupMenuItem(- value: 2,- child: Row(- mainAxisSize: MainAxisSize.min,- children: [Text("COVER")],- ),+ ),+ PopupMenuItem(+ value: 2,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [Text("COVER")],),- PopupMenuItem(- value: 3,- child: Row(- mainAxisSize: MainAxisSize.min,- children: [Text("FILL")],- ),+ ),+ PopupMenuItem(+ value: 3,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [Text("FILL")],),- ];- },- onSelected: (value) {- playerController.aspectRatioType = value;- },+ ),+ ];+ },+ onSelected: (value) {+ playerController.aspectRatioType = value;+ },+ ),+ TextButton(+ style: ButtonStyle(+ padding: WidgetStateProperty.all(EdgeInsets.zero),),- TextButton(- style: ButtonStyle(- padding: WidgetStateProperty.all(EdgeInsets.zero),- ),- onPressed: () {- // 倍速播放- showSetSpeedSheet();- },- child: Text(- '${playerController.playerSpeed}X',- style: const TextStyle(- color: Colors.white,- fontSize: 12,- fontWeight: FontWeight.bold),- ),+ onPressed: () {+ // 倍速播放+ showSetSpeedSheet();+ },+ child: Text(+ '${playerController.playerSpeed}X',+ style: const TextStyle(+ color: Colors.white,+ fontSize: 12,+ fontWeight: FontWeight.bold),),- forwardIcon(),- // 追番- CollectButton(bangumiItem: infoController.bangumiItem),- PopupMenuButton(- tooltip: '',- icon: const Icon(- Icons.more_vert,- color: Colors.white,- ),- itemBuilder: (context) {- return const [- PopupMenuItem(- value: 0,- child: Row(- mainAxisSize: MainAxisSize.min,- children: [Text("弹幕设置")],- ),+ ),+ forwardIcon(),+ // 追番+ CollectButton(bangumiItem: infoController.bangumiItem),+ PopupMenuButton(+ tooltip: '',+ icon: const Icon(+ Icons.more_vert,+ color: Colors.white,+ ),+ itemBuilder: (context) {+ return const [+ PopupMenuItem(+ value: 0,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [Text("弹幕设置")],),- PopupMenuItem(- value: 1,- child: Row(- mainAxisSize: MainAxisSize.min,- children: [Text("弹幕切换")],- ),+ ),+ PopupMenuItem(+ value: 1,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [Text("弹幕切换")],),- PopupMenuItem(- value: 2,- child: Row(- mainAxisSize: MainAxisSize.min,- children: [Text("视频详情")],- ),+ ),+ PopupMenuItem(+ value: 2,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [Text("视频详情")],),- PopupMenuItem(- value: 3,- child: Row(- mainAxisSize: MainAxisSize.min,- children: [Text("远程播放")],- ),+ ),+ PopupMenuItem(+ value: 3,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [Text("远程播放")],),- ];- },- onSelected: (value) {- if (value == 0) {- KazumiDialog.show(builder: (context) {- return DanmakuSettingsWindow(- danmakuController: playerController.danmakuController);- });- }- if (value == 1) {- widget.showDanmakuSwitch();- }- if (value == 2) {- showVideoInfo();- }- if (value == 3) {- bool needRestart = playerController.playing;- playerController.pause();- RemotePlay()- .castVideo(context,- videoPageController.currentPlugin.referer)- .whenComplete(() {- if (needRestart) {- playerController.play();- }- });- }- },- )- ],- ),+ ),+ ];+ },+ onSelected: (value) {+ if (value == 0) {+ KazumiDialog.show(builder: (context) {+ return DanmakuSettingsWindow(+ danmakuController:+ playerController.danmakuController);+ });+ }+ if (value == 1) {+ widget.showDanmakuSwitch();+ }+ if (value == 2) {+ showVideoInfo();+ }+ if (value == 3) {+ bool needRestart = playerController.playing;+ playerController.pause();+ RemotePlay()+ .castVideo(context,+ videoPageController.currentPlugin.referer)+ .whenComplete(() {+ if (needRestart) {+ playerController.play();+ }+ });+ }+ },+ )+ ],),),),- // 自定义播放器底部组件- Positioned(- bottom: 0,- left: 0,- right: 0,- child: Visibility(- visible: !playerController.lockPanel,- child: SlideTransition(- position: playerController.bottomOffsetAnimation,- child: Row(- children: [- IconButton(- color: Colors.white,- icon: Icon(playerController.playing- ? Icons.pause- : Icons.play_arrow),- onPressed: () {- playerController.playOrPause();- },- ),- // 更换选集- (videoPageController.isFullscreen ||- Utils.isTablet() ||- Utils.isDesktop())- ? IconButton(- color: Colors.white,- icon: const Icon(Icons.skip_next),- onPressed: () {- if (videoPageController.loading) {- return;- }- if (videoPageController.currentEpisode ==- videoPageController- .roadList[- videoPageController.currentRoad]- .data- .length) {- KazumiDialog.showToast(- message: '已经是最新一集',- );- return;- }+ ),+ // 自定义播放器底部组件+ Positioned(+ bottom: 0,+ left: 0,+ right: 0,+ child: Visibility(+ visible: !playerController.lockPanel,+ child: SlideTransition(+ position: playerController.bottomOffsetAnimation,+ child: Row(+ children: [+ IconButton(+ color: Colors.white,+ icon: Icon(playerController.playing+ ? Icons.pause+ : Icons.play_arrow),+ onPressed: () {+ playerController.playOrPause();+ },+ ),+ // 更换选集+ (videoPageController.isFullscreen ||+ Utils.isTablet() ||+ Utils.isDesktop())+ ? IconButton(+ color: Colors.white,+ icon: const Icon(Icons.skip_next),+ onPressed: () {+ if (videoPageController.loading) {+ return;+ }+ if (videoPageController.currentEpisode ==+ videoPageController+ .roadList[videoPageController.currentRoad]+ .data+ .length) {KazumiDialog.showToast(- message:- '正在加载${videoPageController.roadList[videoPageController.currentRoad].identifier[videoPageController.currentEpisode]}');- widget.changeEpisode(- videoPageController.currentEpisode + 1,- currentRoad:- videoPageController.currentRoad);- },- )- : Container(),- Expanded(- child: ProgressBar(- 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();- },- ),- ),- ((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,- ),- ),- ),- // 弹幕相关- (playerController.danmakuOn)- ? IconButton(- color: Colors.white,- icon: const Icon(Icons.notes),- onPressed: () {- if (playerController.danDanmakus.isEmpty) {- KazumiDialog.showToast(- message: '当前剧集不支持弹幕发送的说',- );- return;- }- showShootDanmakuSheet();- },- )- : Container(),- IconButton(- color: Colors.white,- icon: Icon(playerController.danmakuOn- ? Icons.subtitles- : Icons.subtitles_off),- onPressed: () {- _handleDanmaku();+ message: '已经是最新一集',+ );+ return;+ }+ KazumiDialog.showToast(+ message:+ '正在加载${videoPageController.roadList[videoPageController.currentRoad].identifier[videoPageController.currentEpisode]}');+ widget.changeEpisode(+ videoPageController.currentEpisode + 1,+ currentRoad: videoPageController.currentRoad);+ },+ )+ : Container(),+ Expanded(+ child: ProgressBar(+ 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();},),- (!videoPageController.isFullscreen &&- !Utils.isTablet() &&- !Utils.isDesktop())- ? Container()- : IconButton(- color: Colors.white,- icon: Icon(videoPageController.showTabBody- ? Icons.menu_open- : Icons.menu_open_outlined),- 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- : Icons.fullscreen),- onPressed: () {- widget.handleFullscreen();- },+ ),+ ((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,+ ),),- ],- ),+ ),+ // 弹幕相关+ (playerController.danmakuOn)+ ? IconButton(+ color: Colors.white,+ icon: const Icon(Icons.notes),+ onPressed: () {+ if (playerController.danDanmakus.isEmpty) {+ KazumiDialog.showToast(+ message: '当前剧集不支持弹幕发送的说',+ );+ return;+ }+ showShootDanmakuSheet();+ },+ )+ : Container(),+ IconButton(+ color: Colors.white,+ icon: Icon(playerController.danmakuOn+ ? Icons.subtitles+ : Icons.subtitles_off),+ onPressed: () {+ _handleDanmaku();+ },+ ),+ (!videoPageController.isFullscreen &&+ !Utils.isTablet() &&+ !Utils.isDesktop())+ ? Container()+ : IconButton(+ color: Colors.white,+ icon: Icon(videoPageController.showTabBody+ ? Icons.menu_open+ : Icons.menu_open_outlined),+ 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+ : Icons.fullscreen),+ onPressed: () {+ widget.handleFullscreen();+ },+ ),+ ],),),),- ],- );- }),- );+ ),+ ],+ );+ });}}