mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: danmaku showing
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -33,6 +33,7 @@ class LiveRoomController extends GetxController {
|
||||
RxBool disableAutoScroll = false.obs;
|
||||
double? brightness;
|
||||
DanmakuController? controller;
|
||||
bool showDanmaku = true;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -135,17 +136,19 @@ class LiveRoomController extends GetxController {
|
||||
// logger.i(' 原始弹幕消息 ======> ${jsonEncode(obj)}');
|
||||
messages.add(obj);
|
||||
Map json = jsonDecode(obj['info'][0][15]['extra']);
|
||||
controller?.addItems([
|
||||
DanmakuItem(
|
||||
json['content'],
|
||||
color: DmUtils.decimalToColor(json['color']),
|
||||
// time: e.progress,
|
||||
type: DmUtils.getPosition(json['mode']),
|
||||
)
|
||||
]);
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => scrollToBottom(),
|
||||
);
|
||||
if (showDanmaku) {
|
||||
controller?.addItems([
|
||||
DanmakuItem(
|
||||
json['content'],
|
||||
color: DmUtils.decimalToColor(json['color']),
|
||||
// time: e.progress,
|
||||
type: DmUtils.getPosition(json['mode']),
|
||||
)
|
||||
]);
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => scrollToBottom(),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
msgStream?.init();
|
||||
|
||||
@@ -25,7 +25,8 @@ class LiveRoomPage extends StatefulWidget {
|
||||
State<LiveRoomPage> createState() => _LiveRoomPageState();
|
||||
}
|
||||
|
||||
class _LiveRoomPageState extends State<LiveRoomPage> {
|
||||
class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
with WidgetsBindingObserver {
|
||||
late final int _roomId;
|
||||
final LiveRoomController _liveRoomController = Get.put(LiveRoomController());
|
||||
late final PlPlayerController plPlayerController;
|
||||
@@ -57,6 +58,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_roomId = int.parse(Get.parameters['roomid'] ?? '-1');
|
||||
PlPlayerController.setPlayCallBack(playCallBack);
|
||||
if (Platform.isAndroid) {
|
||||
@@ -82,6 +84,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
ScreenBrightness().resetApplicationScreenBrightness();
|
||||
PlPlayerController.setPlayCallBack(null);
|
||||
floating?.dispose();
|
||||
@@ -94,6 +97,16 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
_liveRoomController.showDanmaku = true;
|
||||
} else if (state == AppLifecycleState.paused) {
|
||||
_liveRoomController.showDanmaku = false;
|
||||
plPlayerController.danmakuController?.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget videoPlayerPanel = FutureBuilder(
|
||||
|
||||
Reference in New Issue
Block a user