mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
opt: video page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -74,7 +74,6 @@ class VideoIntroController extends GetxController
|
||||
bool isShowOnlineTotal = false;
|
||||
RxString total = '1'.obs;
|
||||
Timer? timer;
|
||||
bool isPaused = false;
|
||||
String heroTag = '';
|
||||
late ModelResult modelResult;
|
||||
Rx<Map<String, dynamic>> queryVideoIntroData =
|
||||
@@ -574,11 +573,8 @@ class VideoIntroController extends GetxController
|
||||
void startTimer() {
|
||||
if (isShowOnlineTotal) {
|
||||
queryOnlineTotal();
|
||||
const duration = Duration(seconds: 10); // 设置定时器间隔为10秒
|
||||
timer ??= Timer.periodic(duration, (Timer timer) {
|
||||
if (!isPaused) {
|
||||
queryOnlineTotal(); // 定时器回调函数,发起请求
|
||||
}
|
||||
timer ??= Timer.periodic(const Duration(seconds: 10), (Timer timer) {
|
||||
queryOnlineTotal();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -606,9 +602,7 @@ class VideoIntroController extends GetxController
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
if (timer != null) {
|
||||
timer!.cancel(); // 销毁页面时取消定时器
|
||||
}
|
||||
canelTimer();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class VideoDetailPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
with TickerProviderStateMixin, RouteAware {
|
||||
with TickerProviderStateMixin, RouteAware, WidgetsBindingObserver {
|
||||
late VideoDetailController videoDetailController;
|
||||
late VideoReplyController _videoReplyController;
|
||||
PlPlayerController? plPlayerController;
|
||||
@@ -170,6 +170,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// : context.width * 9 / 16),
|
||||
// end: 0,
|
||||
// ).animate(_animationController);
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
}
|
||||
|
||||
// 获取视频资源,初始化播放器
|
||||
@@ -183,6 +184,17 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
videoIntroController.startTimer();
|
||||
videoDetailController.plPlayerController.showDanmaku = true;
|
||||
} else if (state == AppLifecycleState.paused) {
|
||||
videoIntroController.canelTimer();
|
||||
videoDetailController.plPlayerController.showDanmaku = false;
|
||||
}
|
||||
}
|
||||
|
||||
void playCallBack() {
|
||||
plPlayerController?.play();
|
||||
}
|
||||
@@ -241,7 +253,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
Future<void> handlePlay() async {
|
||||
if (videoDetailController.videoUrl == null ||
|
||||
videoDetailController.audioUrl == null) {
|
||||
SmartDialog.showToast('not initialized');
|
||||
// SmartDialog.showToast('not initialized');
|
||||
debugPrint('not initialized');
|
||||
return;
|
||||
}
|
||||
plPlayerController = videoDetailController.plPlayerController;
|
||||
@@ -275,6 +288,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
if (!Get.previousRoute.startsWith('/video')) {
|
||||
ScreenBrightness().resetApplicationScreenBrightness();
|
||||
PlPlayerController.setPlayCallBack(null);
|
||||
@@ -325,7 +339,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
if (plPlayerController != null) {
|
||||
videoDetailController.defaultST = plPlayerController!.position.value;
|
||||
videoIntroController.isPaused = true;
|
||||
plPlayerController!.removeStatusLister(playerListener);
|
||||
plPlayerController!.pause();
|
||||
}
|
||||
@@ -369,7 +382,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// }
|
||||
|
||||
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
|
||||
videoIntroController.isPaused = false;
|
||||
// if (autoplay) {
|
||||
// // await Future.delayed(const Duration(milliseconds: 300));
|
||||
// debugPrint(plPlayerController);
|
||||
|
||||
Reference in New Issue
Block a user