mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-01 23:59:50 +08:00
@@ -102,8 +102,6 @@ class VideoDetailController extends GetxController
|
||||
late VideoDecodeFormatType currentDecodeFormats;
|
||||
// 是否开始自动播放 存在多p的情况下,第二p需要为true
|
||||
final RxBool autoPlay = true.obs;
|
||||
// 封面图的展示
|
||||
final RxBool isShowCover = true.obs;
|
||||
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final childKey = GlobalKey<ScaffoldState>();
|
||||
@@ -285,7 +283,6 @@ class VideoDetailController extends GetxController
|
||||
);
|
||||
|
||||
autoPlay.value = Pref.autoPlayEnable;
|
||||
if (autoPlay.value) isShowCover.value = false;
|
||||
|
||||
// 预设的解码格式
|
||||
cacheDecode = Pref.defaultDecode;
|
||||
@@ -732,7 +729,7 @@ class VideoDetailController extends GetxController
|
||||
);
|
||||
|
||||
if (positionSubscription == null &&
|
||||
!isShowCover.value &&
|
||||
autoPlay.value &&
|
||||
plPlayerController.videoPlayerController != null) {
|
||||
final currPost =
|
||||
plPlayerController.position.value.inMilliseconds;
|
||||
@@ -781,7 +778,7 @@ class VideoDetailController extends GetxController
|
||||
);
|
||||
|
||||
if (positionSubscription == null &&
|
||||
(!isShowCover.value || plPlayerController.preInitPlayer)) {
|
||||
(autoPlay.value || plPlayerController.preInitPlayer)) {
|
||||
initSkip();
|
||||
plPlayerController.segmentList.value = segmentProgressList!;
|
||||
}
|
||||
@@ -799,7 +796,7 @@ class VideoDetailController extends GetxController
|
||||
?.stream
|
||||
.position
|
||||
.listen((position) {
|
||||
if (isShowCover.value) {
|
||||
if (!autoPlay.value) {
|
||||
return;
|
||||
}
|
||||
int currentPos = position.inSeconds;
|
||||
@@ -1000,7 +997,7 @@ class VideoDetailController extends GetxController
|
||||
|
||||
/// 更新画质、音质
|
||||
void updatePlayer() {
|
||||
isShowCover.value = false;
|
||||
autoPlay.value = true;
|
||||
playedTime = plPlayerController.position.value;
|
||||
plPlayerController.removeListeners();
|
||||
plPlayerController.isBuffering.value = false;
|
||||
@@ -1209,10 +1206,7 @@ class VideoDetailController extends GetxController
|
||||
setVideoHeight();
|
||||
currentDecodeFormats = VideoDecodeFormatTypeExt.fromString('avc1')!;
|
||||
currentVideoQa = VideoQuality.fromCode(data.quality!);
|
||||
if (autoPlay.value) {
|
||||
isShowCover.value = false;
|
||||
await playerInit();
|
||||
} else if (plPlayerController.preInitPlayer) {
|
||||
if (autoPlay.value || plPlayerController.preInitPlayer) {
|
||||
await playerInit();
|
||||
}
|
||||
isQuerying = false;
|
||||
@@ -1221,7 +1215,6 @@ class VideoDetailController extends GetxController
|
||||
if (data.dash == null) {
|
||||
SmartDialog.showToast('视频资源不存在');
|
||||
autoPlay.value = false;
|
||||
isShowCover.value = true;
|
||||
videoState.value = const Error('视频资源不存在');
|
||||
if (plPlayerController.isFullScreen.value) {
|
||||
plPlayerController.toggleFullScreen(false);
|
||||
@@ -1340,15 +1333,11 @@ class VideoDetailController extends GetxController
|
||||
? Duration.zero
|
||||
: Duration(milliseconds: data.lastPlayTime!));
|
||||
}
|
||||
if (autoPlay.value) {
|
||||
isShowCover.value = false;
|
||||
await playerInit();
|
||||
} else if (plPlayerController.preInitPlayer) {
|
||||
if (autoPlay.value || plPlayerController.preInitPlayer) {
|
||||
await playerInit();
|
||||
}
|
||||
} else {
|
||||
autoPlay.value = false;
|
||||
isShowCover.value = true;
|
||||
videoState.value = Error(result['msg']);
|
||||
if (plPlayerController.isFullScreen.value) {
|
||||
plPlayerController.toggleFullScreen(false);
|
||||
|
||||
@@ -121,6 +121,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
|
||||
final GlobalKey relatedVideoPanelKey = GlobalKey();
|
||||
final GlobalKey videoPlayerKey = GlobalKey();
|
||||
final GlobalKey playerKey = GlobalKey();
|
||||
final GlobalKey videoReplyPanelKey = GlobalKey();
|
||||
late final GlobalKey ugcPanelKey = GlobalKey();
|
||||
late final GlobalKey pgcPanelKey = GlobalKey();
|
||||
@@ -188,24 +189,26 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
introController.startTimer();
|
||||
videoDetailController.plPlayerController.showDanmaku = true;
|
||||
if (!videoDetailController.plPlayerController.showDanmaku) {
|
||||
introController.startTimer();
|
||||
videoDetailController.plPlayerController.showDanmaku = true;
|
||||
|
||||
// 修复从后台恢复时全屏状态下屏幕方向错误的问题
|
||||
if (isFullScreen && Platform.isIOS) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// 根据视频方向重新设置屏幕方向
|
||||
final isVertical = videoDetailController.isVertical.value;
|
||||
final mode = plPlayerController?.mode;
|
||||
// 修复从后台恢复时全屏状态下屏幕方向错误的问题
|
||||
if (isFullScreen && Platform.isIOS) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// 根据视频方向重新设置屏幕方向
|
||||
final isVertical = videoDetailController.isVertical.value;
|
||||
final mode = plPlayerController?.mode;
|
||||
|
||||
late final size = Get.size;
|
||||
if (!(mode == FullScreenMode.vertical ||
|
||||
(mode == FullScreenMode.auto && isVertical) ||
|
||||
(mode == FullScreenMode.ratio &&
|
||||
(isVertical || size.height / size.width < 1.25)))) {
|
||||
landScape();
|
||||
}
|
||||
});
|
||||
late final size = Get.size;
|
||||
if (!(mode == FullScreenMode.vertical ||
|
||||
(mode == FullScreenMode.auto && isVertical) ||
|
||||
(mode == FullScreenMode.ratio &&
|
||||
(isVertical || size.height / size.width < 1.25)))) {
|
||||
landScape();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (state == AppLifecycleState.paused) {
|
||||
introController.canelTimer();
|
||||
@@ -317,9 +320,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
return;
|
||||
}
|
||||
plPlayerController = videoDetailController.plPlayerController;
|
||||
videoDetailController
|
||||
..isShowCover.value = false
|
||||
..autoPlay.value = true;
|
||||
videoDetailController.autoPlay.value = true;
|
||||
if (videoDetailController.plPlayerController.preInitPlayer) {
|
||||
await plPlayerController!.play();
|
||||
} else {
|
||||
@@ -452,9 +453,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
}
|
||||
}
|
||||
super.didPopNext();
|
||||
final isShowCover = videoDetailController.isShowCover.value;
|
||||
videoDetailController.autoPlay.value = !isShowCover;
|
||||
if (!isShowCover) {
|
||||
if (videoDetailController.autoPlay.value) {
|
||||
await videoDetailController.playerInit(
|
||||
autoplay: videoDetailController.playerStatus == PlayerStatus.playing,
|
||||
);
|
||||
@@ -1212,41 +1211,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
),
|
||||
);
|
||||
|
||||
Widget get childWhenEnabled => Obx(
|
||||
() => !videoDetailController.autoPlay.value
|
||||
? const SizedBox.shrink()
|
||||
: PLVideoPlayer(
|
||||
key: Key(heroTag),
|
||||
plPlayerController: plPlayerController!,
|
||||
videoDetailController: videoDetailController,
|
||||
ugcIntroController: videoDetailController.isUgc
|
||||
? ugcIntroController
|
||||
: null,
|
||||
pgcIntroController: videoDetailController.isUgc
|
||||
? null
|
||||
: pgcIntroController,
|
||||
headerControl: HeaderControl(
|
||||
controller: plPlayerController!,
|
||||
videoDetailCtr: videoDetailController,
|
||||
heroTag: heroTag,
|
||||
),
|
||||
danmuWidget: pipNoDanmaku
|
||||
? null
|
||||
: Obx(
|
||||
() => PlDanmaku(
|
||||
key: Key(videoDetailController.cid.value.toString()),
|
||||
isPipMode: true,
|
||||
cid: videoDetailController.cid.value,
|
||||
playerController: plPlayerController!,
|
||||
),
|
||||
),
|
||||
showEpisodes: showEpisodes,
|
||||
showViewPoints: showViewPoints,
|
||||
),
|
||||
);
|
||||
|
||||
Widget get manualPlayerWidget => Obx(() {
|
||||
if (videoDetailController.isShowCover.value) {
|
||||
if (!videoDetailController.autoPlay.value) {
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
@@ -1387,15 +1353,15 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
return const SizedBox.shrink();
|
||||
});
|
||||
|
||||
Widget get plPlayer => Obx(
|
||||
Widget plPlayer([bool isPipMode = false]) => Obx(
|
||||
key: videoPlayerKey,
|
||||
() => videoDetailController.videoState.value is! Success
|
||||
? const SizedBox.shrink()
|
||||
: !videoDetailController.autoPlay.value ||
|
||||
plPlayerController?.videoController == null
|
||||
() =>
|
||||
videoDetailController.videoState.value is! Success ||
|
||||
!videoDetailController.autoPlay.value ||
|
||||
plPlayerController?.videoController == null
|
||||
? const SizedBox.shrink()
|
||||
: PLVideoPlayer(
|
||||
key: Key(heroTag),
|
||||
key: playerKey,
|
||||
plPlayerController: plPlayerController!,
|
||||
videoDetailController: videoDetailController,
|
||||
ugcIntroController: videoDetailController.isUgc
|
||||
@@ -1410,13 +1376,17 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
videoDetailCtr: videoDetailController,
|
||||
heroTag: heroTag,
|
||||
),
|
||||
danmuWidget: Obx(
|
||||
() => PlDanmaku(
|
||||
key: Key(videoDetailController.cid.value.toString()),
|
||||
cid: videoDetailController.cid.value,
|
||||
playerController: plPlayerController!,
|
||||
),
|
||||
),
|
||||
danmuWidget: isPipMode && pipNoDanmaku
|
||||
? null
|
||||
: Obx(
|
||||
() => PlDanmaku(
|
||||
key: ValueKey(videoDetailController.cid.value),
|
||||
isPipMode: isPipMode,
|
||||
cid: videoDetailController.cid.value,
|
||||
playerController: plPlayerController!,
|
||||
isFullScreen: plPlayerController!.isFullScreen.value,
|
||||
),
|
||||
),
|
||||
showEpisodes: showEpisodes,
|
||||
showViewPoints: showViewPoints,
|
||||
),
|
||||
@@ -1424,7 +1394,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
|
||||
Widget autoChoose(Widget childWhenDisabled) {
|
||||
if (Platform.isAndroid) {
|
||||
return Floating().isPipMode ? childWhenEnabled : childWhenDisabled;
|
||||
return Floating().isPipMode ? plPlayer(true) : childWhenDisabled;
|
||||
}
|
||||
return childWhenDisabled;
|
||||
}
|
||||
@@ -1624,10 +1594,10 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
children: [
|
||||
const Positioned.fill(child: ColoredBox(color: Colors.black)),
|
||||
|
||||
if (isShowing) plPlayer,
|
||||
if (isShowing) plPlayer(),
|
||||
|
||||
Obx(() {
|
||||
if (videoDetailController.isShowCover.value) {
|
||||
if (!videoDetailController.autoPlay.value) {
|
||||
return Positioned.fill(
|
||||
child: GestureDetector(
|
||||
onTap: handlePlay,
|
||||
|
||||
Reference in New Issue
Block a user