mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 提前关闭封面、点击小电视强制尝试播放
This commit is contained in:
@@ -117,6 +117,7 @@ class VideoDetailController extends GetxController
|
|||||||
length: 2, vsync: this, initialIndex: defaultShowComment ? 1 : 0);
|
length: 2, vsync: this, initialIndex: defaultShowComment ? 1 : 0);
|
||||||
autoPlay.value =
|
autoPlay.value =
|
||||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
||||||
|
if (autoPlay.value) isShowCover.value = false;
|
||||||
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
|
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
|
||||||
hwdec.value = setting.get(SettingBoxKey.hardwareDecoding,
|
hwdec.value = setting.get(SettingBoxKey.hardwareDecoding,
|
||||||
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto');
|
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto');
|
||||||
@@ -319,8 +320,8 @@ class VideoDetailController extends GetxController
|
|||||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString('avc1')!;
|
currentDecodeFormats = VideoDecodeFormatsCode.fromString('avc1')!;
|
||||||
currentVideoQa = VideoQualityCode.fromCode(data.quality!)!;
|
currentVideoQa = VideoQualityCode.fromCode(data.quality!)!;
|
||||||
if (autoPlay.value) {
|
if (autoPlay.value) {
|
||||||
await playerInit();
|
|
||||||
isShowCover.value = false;
|
isShowCover.value = false;
|
||||||
|
await playerInit();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -421,8 +422,8 @@ class VideoDetailController extends GetxController
|
|||||||
}
|
}
|
||||||
defaultST = Duration(milliseconds: data.lastPlayTime!);
|
defaultST = Duration(milliseconds: data.lastPlayTime!);
|
||||||
if (autoPlay.value) {
|
if (autoPlay.value) {
|
||||||
await playerInit();
|
|
||||||
isShowCover.value = false;
|
isShowCover.value = false;
|
||||||
|
await playerInit();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (result['code'] == -404) {
|
if (result['code'] == -404) {
|
||||||
|
|||||||
@@ -200,13 +200,13 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
|
|
||||||
/// 未开启自动播放时触发播放
|
/// 未开启自动播放时触发播放
|
||||||
Future<void> handlePlay() async {
|
Future<void> handlePlay() async {
|
||||||
|
videoDetailController.isShowCover.value = false;
|
||||||
await videoDetailController.playerInit();
|
await videoDetailController.playerInit();
|
||||||
plPlayerController = videoDetailController.plPlayerController;
|
plPlayerController = videoDetailController.plPlayerController;
|
||||||
plPlayerController!.addStatusLister(playerListener);
|
plPlayerController!.addStatusLister(playerListener);
|
||||||
listenFullScreenStatus();
|
listenFullScreenStatus();
|
||||||
await plPlayerController!.autoEnterFullscreen();
|
await plPlayerController!.autoEnterFullscreen();
|
||||||
videoDetailController.autoPlay.value = true;
|
videoDetailController.autoPlay.value = true;
|
||||||
videoDetailController.isShowCover.value = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // 生命周期监听
|
// // 生命周期监听
|
||||||
@@ -310,11 +310,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
super.didPopNext();
|
super.didPopNext();
|
||||||
videoDetailController.isFirstTime = false;
|
videoDetailController.isFirstTime = false;
|
||||||
final bool autoplay = autoPlayEnable;
|
final bool autoplay = autoPlayEnable;
|
||||||
|
videoDetailController.autoPlay.value =
|
||||||
|
!videoDetailController.isShowCover.value;
|
||||||
await videoDetailController.playerInit(autoplay: autoplay);
|
await videoDetailController.playerInit(autoplay: autoplay);
|
||||||
|
|
||||||
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
|
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
|
||||||
videoDetailController.autoPlay.value =
|
|
||||||
!videoDetailController.isShowCover.value;
|
|
||||||
videoIntroController.isPaused = false;
|
videoIntroController.isPaused = false;
|
||||||
// if (autoplay) {
|
// if (autoplay) {
|
||||||
// // await Future.delayed(const Duration(milliseconds: 300));
|
// // await Future.delayed(const Duration(milliseconds: 300));
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ class PlPlayerController {
|
|||||||
int _cid = 0;
|
int _cid = 0;
|
||||||
int _heartDuration = 0;
|
int _heartDuration = 0;
|
||||||
bool _enableHeart = true;
|
bool _enableHeart = true;
|
||||||
|
|
||||||
|
late DataSource dataSource;
|
||||||
final RxList<Map<String, String>> _vttSubtitles = <Map<String, String>>[].obs;
|
final RxList<Map<String, String>> _vttSubtitles = <Map<String, String>>[].obs;
|
||||||
final RxInt _vttSubtitlesIndex = 0.obs;
|
final RxInt _vttSubtitlesIndex = 0.obs;
|
||||||
|
|
||||||
@@ -411,6 +413,7 @@ class PlPlayerController {
|
|||||||
bool enableHeart = true,
|
bool enableHeart = true,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
|
this.dataSource = dataSource;
|
||||||
_autoPlay = autoplay;
|
_autoPlay = autoplay;
|
||||||
_looping = looping;
|
_looping = looping;
|
||||||
// 初始化视频倍速
|
// 初始化视频倍速
|
||||||
@@ -595,6 +598,16 @@ class PlPlayerController {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future refreshPlayer() async {
|
||||||
|
await _videoPlayerController?.open(
|
||||||
|
Media(
|
||||||
|
dataSource.videoSource!,
|
||||||
|
httpHeaders: dataSource.httpHeaders,
|
||||||
|
),
|
||||||
|
play: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// 开始播放
|
// 开始播放
|
||||||
Future _initializePlayer({
|
Future _initializePlayer({
|
||||||
Duration seekTo = Duration.zero,
|
Duration seekTo = Duration.zero,
|
||||||
@@ -1102,6 +1115,8 @@ class PlPlayerController {
|
|||||||
Future<void> triggerFullScreen({bool status = true}) async {
|
Future<void> triggerFullScreen({bool status = true}) async {
|
||||||
FullScreenMode mode = FullScreenModeCode.fromCode(
|
FullScreenMode mode = FullScreenModeCode.fromCode(
|
||||||
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
|
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
|
||||||
|
bool removeSafeArea = setting.get(SettingBoxKey.videoPlayerRemoveSafeArea,
|
||||||
|
defaultValue: false);
|
||||||
if (!isFullScreen.value && status) {
|
if (!isFullScreen.value && status) {
|
||||||
// StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
|
// StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
|
||||||
hideStatusBar();
|
hideStatusBar();
|
||||||
@@ -1124,7 +1139,7 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
} else if (isFullScreen.value && !status) {
|
} else if (isFullScreen.value && !status) {
|
||||||
// StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
// StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
||||||
showStatusBar();
|
if (!removeSafeArea) showStatusBar();
|
||||||
toggleFullScreen(false);
|
toggleFullScreen(false);
|
||||||
if (mode == FullScreenMode.none) {
|
if (mode == FullScreenMode.none) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1043,7 +1043,12 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
Obx(() {
|
Obx(() {
|
||||||
if (_.dataStatus.loading || _.isBuffering.value) {
|
if (_.dataStatus.loading || _.isBuffering.value) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Container(
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
_.refreshPlayer();
|
||||||
|
},
|
||||||
|
child:
|
||||||
|
Container(
|
||||||
padding: const EdgeInsets.all(30),
|
padding: const EdgeInsets.all(30),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
@@ -1057,7 +1062,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
semanticLabel: "加载中",
|
semanticLabel: "加载中",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user