Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-29 10:19:37 +08:00
parent 6d599891dc
commit 1f77ee178e
3 changed files with 40 additions and 48 deletions

View File

@@ -111,17 +111,6 @@ class LiveRoomController extends GetxController {
}
}
void setVolume(value) {
if (value == 0) {
// 设置音量
volumeOff.value = false;
} else {
// 取消音量
volume = value;
volumeOff.value = true;
}
}
Future<void> queryLiveInfoH5() async {
var res = await LiveHttp.liveRoomInfoH5(roomId: roomId);
if (res['status']) {
@@ -152,20 +141,22 @@ class LiveRoomController extends GetxController {
if (messages.isEmpty) {
LiveHttp.liveRoomDanmaPrefetch(roomId: roomId).then((v) {
if (v['status']) {
messages.addAll((v['data'] as List)
.map((obj) => {
'name': obj['user']['base']['name'],
'uid': obj['user']['uid'],
'text': obj['text'],
'emots': obj['emots'],
'uemote': obj['emoticon']['emoticon_unique'] != ""
? obj['emoticon']
: null,
})
.toList());
WidgetsBinding.instance.addPostFrameCallback(
(_) => scrollToBottom(),
);
if ((v['data'] as List?)?.isNotEmpty == true) {
messages.addAll((v['data'] as List)
.map((obj) => {
'name': obj['user']['base']['name'],
'uid': obj['user']['uid'],
'text': obj['text'],
'emots': obj['emots'],
'uemote': obj['emoticon']['emoticon_unique'] != ""
? obj['emoticon']
: null,
})
.toList());
WidgetsBinding.instance.addPostFrameCallback(
(_) => scrollToBottom(),
);
}
}
});
}
@@ -186,25 +177,28 @@ class LiveRoomController extends GetxController {
msgStream?.addEventListener((obj) {
if (obj['cmd'] == 'DANMU_MSG') {
// logger.i(' 原始弹幕消息 ======> ${jsonEncode(obj)}');
final info = obj['info'];
final first = info[0];
final content = first[15];
final extra = jsonDecode(content['extra']);
final user = content['user'];
messages.add({
'name': obj['info'][0][15]['user']['base']['name'],
'uid': obj['info'][0][15]['user']['uid'],
'text': obj['info'][1],
'emots': jsonDecode(obj['info'][0][15]['extra'])['emots'],
'uemote': obj['info'][0][13],
'name': user['base']['name'],
'uid': user['uid'],
'text': info[1],
'emots': extra['emots'],
'uemote': first[13],
});
Map json = jsonDecode(obj['info'][0][15]['extra']);
if (showDanmaku) {
controller?.addDanmaku(
DanmakuContentItem(
json['content'],
color: DmUtils.decimalToColor(json['color']),
type: DmUtils.getPosition(json['mode']),
extra['content'],
color: DmUtils.decimalToColor(extra['color']),
type: DmUtils.getPosition(extra['mode']),
),
);
WidgetsBinding.instance.addPostFrameCallback(
(_) => scrollToBottom(),
);
WidgetsBinding.instance
.addPostFrameCallback((_) => scrollToBottom());
}
}
});