opt player

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-10 14:10:34 +08:00
parent dbde90459b
commit 8fbc8fda3d
4 changed files with 64 additions and 63 deletions

View File

@@ -100,7 +100,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
videoDetailController.plPlayerController.removeSafeArea; videoDetailController.plPlayerController.removeSafeArea;
bool isShowing = true; bool isShowing = true;
bool get isFullScreen => plPlayerController?.isFullScreen.value ?? false; bool get isFullScreen =>
videoDetailController.plPlayerController.isFullScreen.value;
bool get _shouldShowSeasonPanel { bool get _shouldShowSeasonPanel {
if (isPortrait || !videoDetailController.isUgc) { if (isPortrait || !videoDetailController.isUgc) {
@@ -1110,9 +1111,10 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
width = min(width, maxWidth - 280); width = min(width, maxWidth - 280);
} }
final videoWidth = isFullScreen ? maxWidth : width; final videoWidth = isFullScreen ? maxWidth : width;
final double videoHeight = isFullScreen ? maxHeight : width * 9 / 16; final double height = width * 9 / 16;
final videoHeight = isFullScreen ? maxHeight : height;
final introHeight = final introHeight =
maxHeight - videoHeight - (removeSafeArea ? 0 : padding.top); maxHeight - height - (removeSafeArea ? 0 : padding.top);
return Row( return Row(
children: [ children: [
Column( Column(
@@ -1404,6 +1406,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
: pgcIntroController, : pgcIntroController,
headerControl: HeaderControl( headerControl: HeaderControl(
key: videoDetailController.headerCtrKey, key: videoDetailController.headerCtrKey,
isPortrait: isPortrait,
controller: videoDetailController.plPlayerController, controller: videoDetailController.plPlayerController,
videoDetailCtr: videoDetailController, videoDetailCtr: videoDetailController,
heroTag: heroTag, heroTag: heroTag,

View File

@@ -49,11 +49,13 @@ import 'package:share_plus/share_plus.dart';
class HeaderControl extends StatefulWidget { class HeaderControl extends StatefulWidget {
const HeaderControl({ const HeaderControl({
required this.isPortrait,
required this.controller, required this.controller,
required this.videoDetailCtr, required this.videoDetailCtr,
required this.heroTag, required this.heroTag,
super.key, super.key,
}); });
final bool isPortrait;
final PlPlayerController controller; final PlPlayerController controller;
final VideoDetailController videoDetailCtr; final VideoDetailController videoDetailCtr;
final String heroTag; final String heroTag;
@@ -75,7 +77,8 @@ class HeaderControlState extends TripleState<HeaderControl> {
late CommonIntroController introController = videoDetailCtr.isUgc late CommonIntroController introController = videoDetailCtr.isUgc
? ugcIntroController ? ugcIntroController
: pgcIntroController; : pgcIntroController;
bool get horizontalScreen => videoDetailCtr.horizontalScreen; late final isPortrait = widget.isPortrait;
late final horizontalScreen = videoDetailCtr.horizontalScreen;
RxString now = ''.obs; RxString now = ''.obs;
Timer? clock; Timer? clock;
bool get isFullScreen => widget.controller.isFullScreen.value; bool get isFullScreen => widget.controller.isFullScreen.value;
@@ -1346,7 +1349,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
..danmakuFontScaleFS = fontSizeFS ..danmakuFontScaleFS = fontSizeFS
..putDanmakuSettings(); ..putDanmakuSettings();
setState(() {}); setState(() {});
if (widget.controller.isFullScreen.value == true) { if (isFullScreen) {
try { try {
danmakuController?.updateOption( danmakuController?.updateOption(
danmakuController.option.copyWith( danmakuController.option.copyWith(
@@ -1363,7 +1366,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
..danmakuFontScale = fontSize ..danmakuFontScale = fontSize
..putDanmakuSettings(); ..putDanmakuSettings();
setState(() {}); setState(() {});
if (widget.controller.isFullScreen.value == false) { if (!isFullScreen) {
try { try {
danmakuController?.updateOption( danmakuController?.updateOption(
danmakuController.option.copyWith( danmakuController.option.copyWith(
@@ -1878,7 +1881,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
onPressed: () { onPressed: () {
if (isFullScreen) { if (isFullScreen) {
widget.controller.triggerFullScreen(status: false); widget.controller.triggerFullScreen(status: false);
} else if (!horizontalScreen && context.isLandscape) { } else if (!horizontalScreen && !isPortrait) {
verticalScreenForTwoSeconds(); verticalScreenForTwoSeconds();
} else { } else {
Get.back(); Get.back();
@@ -1886,7 +1889,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
}, },
), ),
), ),
if (!isFullScreen || context.isLandscape) if (!isFullScreen || !isPortrait)
SizedBox( SizedBox(
width: 42, width: 42,
height: 34, height: 34,
@@ -1904,10 +1907,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
), ),
), ),
if ((introController.videoDetail.value.title != null) && if ((introController.videoDetail.value.title != null) &&
(isFullScreen || (isFullScreen || (!horizontalScreen && !isPortrait)))
(!isFullScreen &&
!horizontalScreen &&
context.isLandscape)))
Expanded( Expanded(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -2007,8 +2007,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
// show current datetime // show current datetime
Obx( Obx(
() { () {
if ((isFullScreen || !horizontalScreen) && if ((isFullScreen || !horizontalScreen) && !isPortrait) {
context.isLandscape) {
startClock(); startClock();
return Text( return Text(
now.value, now.value,

View File

@@ -25,7 +25,6 @@ import 'package:PiliPlus/plugin/pl_player/widgets/bottom_control.dart';
import 'package:PiliPlus/plugin/pl_player/widgets/common_btn.dart'; import 'package:PiliPlus/plugin/pl_player/widgets/common_btn.dart';
import 'package:PiliPlus/plugin/pl_player/widgets/forward_seek.dart'; import 'package:PiliPlus/plugin/pl_player/widgets/forward_seek.dart';
import 'package:PiliPlus/plugin/pl_player/widgets/play_pause_btn.dart'; import 'package:PiliPlus/plugin/pl_player/widgets/play_pause_btn.dart';
import 'package:PiliPlus/utils/context_ext.dart';
import 'package:PiliPlus/utils/duration_util.dart'; import 'package:PiliPlus/utils/duration_util.dart';
import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/id_utils.dart';
@@ -248,7 +247,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
} }
// 动态构建底部控制条 // 动态构建底部控制条
Widget buildBottomControl(double maxWidth) { Widget buildBottomControl(bool isLandscape) {
final videoDetail = introController.videoDetail.value; final videoDetail = introController.videoDetail.value;
final isSeason = videoDetail.ugcSeason != null; final isSeason = videoDetail.ugcSeason != null;
final isPart = videoDetail.pages != null && videoDetail.pages!.length > 1; final isPart = videoDetail.pages != null && videoDetail.pages!.length > 1;
@@ -256,7 +255,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
final isPlayAll = widget.videoDetailController?.isPlayAll == true; final isPlayAll = widget.videoDetailController?.isPlayAll == true;
final anySeason = isSeason || isPart || isPgc || isPlayAll; final anySeason = isSeason || isPart || isPgc || isPlayAll;
final double widgetWidth = isFullScreen && context.isLandscape ? 42 : 35; final double widgetWidth = isLandscape && isFullScreen ? 42 : 35;
Widget progressWidget( Widget progressWidget(
BottomControlType bottomControl, BottomControlType bottomControl,
@@ -379,44 +378,41 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
), ),
/// 超分辨率 /// 超分辨率
BottomControlType.superResolution => BottomControlType.superResolution => Container(
plPlayerController.isAnim height: 30,
? Container( margin: const EdgeInsets.symmetric(horizontal: 10),
height: 30, alignment: Alignment.center,
margin: const EdgeInsets.symmetric(horizontal: 10), child: PopupMenuButton<SuperResolutionType>(
alignment: Alignment.center, initialValue: SuperResolutionType
child: PopupMenuButton<SuperResolutionType>( .values[plPlayerController.superResolutionType],
initialValue: SuperResolutionType color: Colors.black.withValues(alpha: 0.8),
.values[plPlayerController.superResolutionType], itemBuilder: (BuildContext context) {
color: Colors.black.withValues(alpha: 0.8), return SuperResolutionType.values.map((
itemBuilder: (BuildContext context) { SuperResolutionType type,
return SuperResolutionType.values.map(( ) {
SuperResolutionType type, return PopupMenuItem<SuperResolutionType>(
) { height: 35,
return PopupMenuItem<SuperResolutionType>( padding: const EdgeInsets.only(left: 30),
height: 35, value: type,
padding: const EdgeInsets.only(left: 30), onTap: () => plPlayerController.setShader(type.index),
value: type, child: Text(
onTap: () => plPlayerController.setShader(type.index), type.title,
child: Text( style: const TextStyle(
type.title, color: Colors.white,
style: const TextStyle( fontSize: 13,
color: Colors.white,
fontSize: 13,
),
),
);
}).toList();
},
child: Text(
SuperResolutionType
.values[plPlayerController.superResolutionType]
.title,
style: const TextStyle(color: Colors.white, fontSize: 13),
), ),
), ),
) );
: const SizedBox.shrink(), }).toList();
},
child: Text(
SuperResolutionType
.values[plPlayerController.superResolutionType]
.title,
style: const TextStyle(color: Colors.white, fontSize: 13),
),
),
),
/// 分段信息 /// 分段信息
BottomControlType.viewPoints => Obx( BottomControlType.viewPoints => Obx(
@@ -650,7 +646,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
List<BottomControlType> userSpecifyItemRight = [ List<BottomControlType> userSpecifyItemRight = [
BottomControlType.dmChart, BottomControlType.dmChart,
BottomControlType.superResolution, if (plPlayerController.isAnim) BottomControlType.superResolution,
BottomControlType.viewPoints, BottomControlType.viewPoints,
if (anySeason) BottomControlType.episode, if (anySeason) BottomControlType.episode,
if (isFullScreen) BottomControlType.fit, if (isFullScreen) BottomControlType.fit,
@@ -663,12 +659,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
children: [ children: [
...userSpecifyItemLeft.map(progressWidget), ...userSpecifyItemLeft.map(progressWidget),
Expanded( Expanded(
child: FittedBox( child: LayoutBuilder(
child: ConstrainedBox( builder: (context, constraints) => FittedBox(
constraints: BoxConstraints(minWidth: maxWidth), child: ConstrainedBox(
child: Row( constraints: BoxConstraints(minWidth: constraints.maxWidth),
mainAxisAlignment: MainAxisAlignment.end, child: Row(
children: userSpecifyItemRight.map(progressWidget).toList(), mainAxisAlignment: MainAxisAlignment.end,
children: userSpecifyItemRight.map(progressWidget).toList(),
),
), ),
), ),
), ),
@@ -1294,7 +1292,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
widget.bottomControl ?? widget.bottomControl ??
BottomControl( BottomControl(
controller: plPlayerController, controller: plPlayerController,
buildBottomControl: buildBottomControl, buildBottomControl: () =>
buildBottomControl(maxWidth > maxHeight),
maxWidth: maxWidth, maxWidth: maxWidth,
), ),
), ),

View File

@@ -18,7 +18,7 @@ class BottomControl extends StatelessWidget {
}); });
final PlPlayerController controller; final PlPlayerController controller;
final Widget Function(double maxWidth) buildBottomControl; final Widget Function() buildBottomControl;
final double maxWidth; final double maxWidth;
@override @override
@@ -157,7 +157,7 @@ class BottomControl extends StatelessWidget {
); );
}, },
), ),
buildBottomControl(maxWidth), buildBottomControl(),
const SizedBox(height: 12), const SizedBox(height: 12),
], ],
), ),