mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-26 20:16:26 +08:00
opt: video page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -92,12 +92,16 @@ abstract class ReplyController extends CommonController {
|
||||
if (response.response.upper.top != null) {
|
||||
final bool flag = response.response.topReplies.any(
|
||||
(ReplyItemModel reply) =>
|
||||
reply.rpid == response.response.upper.top.rpid) as bool;
|
||||
if (!flag) {
|
||||
reply.rpid != response.response.upper.top.rpid) as bool;
|
||||
if (flag) {
|
||||
replies.insert(0, response.response.upper.top);
|
||||
hasUpTop = true;
|
||||
}
|
||||
}
|
||||
replies.insertAll(0, response.response.topReplies);
|
||||
if (response.response.topReplies != null) {
|
||||
replies.insertAll(0, response.response.topReplies);
|
||||
hasUpTop = true;
|
||||
}
|
||||
} else if (loadingState.value is Success) {
|
||||
replies.insertAll(0, (loadingState.value as Success).response.replies);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class PlDanmaku extends StatefulWidget {
|
||||
State<PlDanmaku> createState() => _PlDanmakuState();
|
||||
}
|
||||
|
||||
class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
||||
class _PlDanmakuState extends State<PlDanmaku> {
|
||||
late PlPlayerController playerController;
|
||||
late PlDanmakuController _plDanmakuController;
|
||||
DanmakuController? _controller;
|
||||
@@ -41,23 +41,11 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
||||
// late double strokeWidth;
|
||||
// late int fontWeight;
|
||||
int latestAddedPosition = -1;
|
||||
bool showDanmaku = true;
|
||||
bool? _isFullScreen;
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
showDanmaku = true;
|
||||
} else if (state == AppLifecycleState.paused) {
|
||||
showDanmaku = false;
|
||||
_controller?.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
enableShowDanmaku =
|
||||
setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: true);
|
||||
_plDanmakuController = PlDanmakuController(
|
||||
@@ -129,7 +117,7 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
||||
List<DanmakuElem>? currentDanmakuList =
|
||||
_plDanmakuController.getCurrentDanmaku(currentPosition);
|
||||
|
||||
if (showDanmaku &&
|
||||
if (playerController.showDanmaku &&
|
||||
playerController.playerStatus.status.value == PlayerStatus.playing &&
|
||||
currentDanmakuList != null &&
|
||||
_controller != null) {
|
||||
@@ -150,7 +138,6 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
playerController.removePositionListener(videoPositionListen);
|
||||
playerController.removeStatusLister(playerListener);
|
||||
_plDanmakuController.dispose();
|
||||
|
||||
@@ -22,7 +22,7 @@ class SponsorBlockPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
final _url = 'https://github.com/hanydd/BilibiliSponsorBlock';
|
||||
static const _url = 'https://github.com/hanydd/BilibiliSponsorBlock';
|
||||
final _textController = TextEditingController();
|
||||
late double _blockLimit;
|
||||
late List<Pair<SegmentType, SkipType>> _blockSettings;
|
||||
@@ -78,7 +78,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
setState(() {
|
||||
_serverStatus = res.statusCode == 200 &&
|
||||
res.data is String &&
|
||||
(double.tryParse(res.data) ?? int.tryParse(res.data)) != null;
|
||||
Utils.isStringNumeric(res.data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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