mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-28 06:20:12 +08:00
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user