Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-07-07 11:54:28 +08:00
parent cae5befa63
commit 1946218df3
21 changed files with 446 additions and 334 deletions

View File

@@ -1,5 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:async' show Timer, StreamSubscription;
import 'dart:convert' show jsonDecode;
import 'dart:math' as math;
import 'package:PiliPlus/common/widgets/dialog/report.dart';
@@ -149,6 +149,27 @@ class LiveRoomController extends GetxController {
return const SizedBox.shrink();
});
StreamSubscription? _sizeSub;
void _onSizeChanged((int, int) value) {
final isVertical = value.$2 > value.$1;
isPortrait.value = isVertical;
plPlayerController.isVertical = isVertical;
}
void _startSizeSub() {
if (isPortrait.value) return;
_stopSizeSub();
_sizeSub = plPlayerController.videoPlayerController?.stream.size.listen(
_onSizeChanged,
);
}
void _stopSizeSub() {
_sizeSub?.cancel();
_sizeSub = null;
}
@override
void onInit() {
super.onInit();
@@ -283,7 +304,7 @@ class LiveRoomController extends GetxController {
currentQnDesc.value =
LiveQuality.fromCode(currentQn)?.desc ?? currentQn.toString();
videoUrl = VideoUtils.getLiveCdnUrl(item, index: liveUrlIndex);
return playerInit();
return playerInit()?.whenComplete(_startSizeSub);
}
Future<void> queryLiveInfoH5() async {
@@ -438,6 +459,7 @@ class LiveRoomController extends GetxController {
@override
void onClose() {
_stopSizeSub();
closeLiveMsg();
cancelLikeTimer();
cancelLiveTimer();