feat: 直播间历史记录

This commit is contained in:
guozhigq
2024-09-29 01:01:45 +08:00
parent c60fd6a73e
commit ec5cc6ff91
3 changed files with 28 additions and 0 deletions

View File

@ -565,4 +565,8 @@ class Api {
/// 直播间发送弹幕
static const String sendLiveMsg = '${HttpString.liveBaseUrl}/msg/send';
/// 直播间记录
static const String liveRoomEntry =
'${HttpString.liveBaseUrl}/xlive/web-room/v1/index/roomEntryAction';
}

View File

@ -117,4 +117,15 @@ class LiveHttp {
};
}
}
// 直播历史记录
static Future liveRoomEntry({required int roomId}) async {
await Request().post(Api.liveRoomEntry, queryParameters: {
'room_id': roomId,
'platform': 'pc',
'csrf_token': await Request.getCsrf(),
'csrf': await Request.getCsrf(),
'visit_id': '',
});
}
}

View File

@ -95,6 +95,7 @@ class LiveRoomController extends GetxController {
autoplay: true,
);
plPlayerController.isOpenDanmu.value = danmakuSwitch.value;
heartBeat();
}
Future queryLiveInfo() async {
@ -278,8 +279,20 @@ class LiveRoomController extends GetxController {
}
}
// 历史记录
void heartBeat() {
LiveHttp.liveRoomEntry(roomId: roomId);
}
String encodeToBase64(String input) {
List<int> bytes = utf8.encode(input);
String base64Str = base64.encode(bytes);
return base64Str;
}
@override
void onClose() {
heartBeat();
plSocket?.onClose();
super.onClose();
}