diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index da3b0cbc..ca5a73be 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -480,6 +480,15 @@ class VideoDetailController extends GetxController getDanmaku(subtitles); } } + headerControl = HeaderControl( + controller: plPlayerController, + videoDetailCtr: this, + floating: floating, + bvid: bvid, + videoType: videoType, + showSubtitleBtn: result['status'] && result['data'].subtitles.isNotEmpty, + ); + plPlayerController.setHeaderControl(headerControl); } // 获取弹幕 diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index f22bf846..d563396d 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -30,7 +30,7 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget { this.floating, this.bvid, this.videoType, - this.showSubtitleBtn, + this.showSubtitleBtn = true, super.key, }); final PlPlayerController? controller; @@ -38,7 +38,7 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget { final Floating? floating; final String? bvid; final SearchType? videoType; - final bool? showSubtitleBtn; + final bool showSubtitleBtn; @override State createState() => _HeaderControlState(); @@ -1326,7 +1326,7 @@ class _HeaderControlState extends State { ], /// 字幕 - if (widget.showSubtitleBtn ?? true) + if (widget.showSubtitleBtn) ComBtn( icon: const Icon( Icons.closed_caption_off, diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index de4cd9df..d1305aa7 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -929,6 +929,11 @@ class PlPlayerController { showControls.value = !val; } + /// 设置/更新顶部控制栏 + void setHeaderControl(PreferredSizeWidget? widget) { + headerControl = widget; + } + void toggleFullScreen(bool val) { _isFullScreen.value = val; }