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

View File

@@ -49,11 +49,13 @@ import 'package:share_plus/share_plus.dart';
class HeaderControl extends StatefulWidget {
const HeaderControl({
required this.isPortrait,
required this.controller,
required this.videoDetailCtr,
required this.heroTag,
super.key,
});
final bool isPortrait;
final PlPlayerController controller;
final VideoDetailController videoDetailCtr;
final String heroTag;
@@ -75,7 +77,8 @@ class HeaderControlState extends TripleState<HeaderControl> {
late CommonIntroController introController = videoDetailCtr.isUgc
? ugcIntroController
: pgcIntroController;
bool get horizontalScreen => videoDetailCtr.horizontalScreen;
late final isPortrait = widget.isPortrait;
late final horizontalScreen = videoDetailCtr.horizontalScreen;
RxString now = ''.obs;
Timer? clock;
bool get isFullScreen => widget.controller.isFullScreen.value;
@@ -1346,7 +1349,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
..danmakuFontScaleFS = fontSizeFS
..putDanmakuSettings();
setState(() {});
if (widget.controller.isFullScreen.value == true) {
if (isFullScreen) {
try {
danmakuController?.updateOption(
danmakuController.option.copyWith(
@@ -1363,7 +1366,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
..danmakuFontScale = fontSize
..putDanmakuSettings();
setState(() {});
if (widget.controller.isFullScreen.value == false) {
if (!isFullScreen) {
try {
danmakuController?.updateOption(
danmakuController.option.copyWith(
@@ -1878,7 +1881,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
onPressed: () {
if (isFullScreen) {
widget.controller.triggerFullScreen(status: false);
} else if (!horizontalScreen && context.isLandscape) {
} else if (!horizontalScreen && !isPortrait) {
verticalScreenForTwoSeconds();
} else {
Get.back();
@@ -1886,7 +1889,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
},
),
),
if (!isFullScreen || context.isLandscape)
if (!isFullScreen || !isPortrait)
SizedBox(
width: 42,
height: 34,
@@ -1904,10 +1907,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
),
),
if ((introController.videoDetail.value.title != null) &&
(isFullScreen ||
(!isFullScreen &&
!horizontalScreen &&
context.isLandscape)))
(isFullScreen || (!horizontalScreen && !isPortrait)))
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -2007,8 +2007,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
// show current datetime
Obx(
() {
if ((isFullScreen || !horizontalScreen) &&
context.isLandscape) {
if ((isFullScreen || !horizontalScreen) && !isPortrait) {
startClock();
return Text(
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/forward_seek.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/extension.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 isSeason = videoDetail.ugcSeason != null;
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 anySeason = isSeason || isPart || isPgc || isPlayAll;
final double widgetWidth = isFullScreen && context.isLandscape ? 42 : 35;
final double widgetWidth = isLandscape && isFullScreen ? 42 : 35;
Widget progressWidget(
BottomControlType bottomControl,
@@ -379,44 +378,41 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
),
/// 超分辨率
BottomControlType.superResolution =>
plPlayerController.isAnim
? Container(
height: 30,
margin: const EdgeInsets.symmetric(horizontal: 10),
alignment: Alignment.center,
child: PopupMenuButton<SuperResolutionType>(
initialValue: SuperResolutionType
.values[plPlayerController.superResolutionType],
color: Colors.black.withValues(alpha: 0.8),
itemBuilder: (BuildContext context) {
return SuperResolutionType.values.map((
SuperResolutionType type,
) {
return PopupMenuItem<SuperResolutionType>(
height: 35,
padding: const EdgeInsets.only(left: 30),
value: type,
onTap: () => plPlayerController.setShader(type.index),
child: Text(
type.title,
style: const TextStyle(
color: Colors.white,
fontSize: 13,
),
),
);
}).toList();
},
child: Text(
SuperResolutionType
.values[plPlayerController.superResolutionType]
.title,
style: const TextStyle(color: Colors.white, fontSize: 13),
BottomControlType.superResolution => Container(
height: 30,
margin: const EdgeInsets.symmetric(horizontal: 10),
alignment: Alignment.center,
child: PopupMenuButton<SuperResolutionType>(
initialValue: SuperResolutionType
.values[plPlayerController.superResolutionType],
color: Colors.black.withValues(alpha: 0.8),
itemBuilder: (BuildContext context) {
return SuperResolutionType.values.map((
SuperResolutionType type,
) {
return PopupMenuItem<SuperResolutionType>(
height: 35,
padding: const EdgeInsets.only(left: 30),
value: type,
onTap: () => plPlayerController.setShader(type.index),
child: Text(
type.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(
@@ -650,7 +646,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
List<BottomControlType> userSpecifyItemRight = [
BottomControlType.dmChart,
BottomControlType.superResolution,
if (plPlayerController.isAnim) BottomControlType.superResolution,
BottomControlType.viewPoints,
if (anySeason) BottomControlType.episode,
if (isFullScreen) BottomControlType.fit,
@@ -663,12 +659,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
children: [
...userSpecifyItemLeft.map(progressWidget),
Expanded(
child: FittedBox(
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: maxWidth),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: userSpecifyItemRight.map(progressWidget).toList(),
child: LayoutBuilder(
builder: (context, constraints) => FittedBox(
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: constraints.maxWidth),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: userSpecifyItemRight.map(progressWidget).toList(),
),
),
),
),
@@ -1294,7 +1292,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
widget.bottomControl ??
BottomControl(
controller: plPlayerController,
buildBottomControl: buildBottomControl,
buildBottomControl: () =>
buildBottomControl(maxWidth > maxHeight),
maxWidth: maxWidth,
),
),

View File

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