diff --git a/lib/http/init.dart b/lib/http/init.dart
index ca1b71b6..231414cd 100644
--- a/lib/http/init.dart
+++ b/lib/http/init.dart
@@ -29,6 +29,7 @@ class Request {
late String systemProxyPort;
static final RegExp spmPrefixExp =
RegExp(r'');
+ static late String buvid;
/// 设置cookie
static setCookie() async {
@@ -70,6 +71,8 @@ class Request {
final String cookieString = cookie
.map((Cookie cookie) => '${cookie.name}=${cookie.value}')
.join('; ');
+
+ buvid = cookie.firstWhere((e) => e.name == 'buvid3').value;
dio.options.headers['cookie'] = cookieString;
}
diff --git a/lib/http/live.dart b/lib/http/live.dart
index e624120e..a405fd58 100644
--- a/lib/http/live.dart
+++ b/lib/http/live.dart
@@ -65,4 +65,23 @@ class LiveHttp {
};
}
}
+
+ // 获取弹幕信息
+ static Future liveDanmakuInfo({roomId}) async {
+ var res = await Request().get(Api.getDanmuInfo, data: {
+ 'id': roomId,
+ });
+ if (res.data['code'] == 0) {
+ return {
+ 'status': true,
+ 'data': res.data['data'],
+ };
+ } else {
+ return {
+ 'status': false,
+ 'data': [],
+ 'msg': res.data['message'],
+ };
+ }
+ }
}
diff --git a/lib/models/live/message.dart b/lib/models/live/message.dart
new file mode 100644
index 00000000..cd0f4b75
--- /dev/null
+++ b/lib/models/live/message.dart
@@ -0,0 +1,101 @@
+class LiveMessageModel {
+ // 消息类型
+ final LiveMessageType type;
+
+ // 用户名
+ final String userName;
+
+ // 信息
+ final String? message;
+
+ // 数据
+ final dynamic data;
+
+ final String? face;
+ final int? uid;
+ final Map? emots;
+
+ // 颜色
+ final LiveMessageColor color;
+
+ LiveMessageModel({
+ required this.type,
+ required this.userName,
+ required this.message,
+ required this.color,
+ this.data,
+ this.face,
+ this.uid,
+ this.emots,
+ });
+}
+
+class LiveSuperChatMessage {
+ final String backgroundBottomColor;
+ final String backgroundColor;
+ final DateTime endTime;
+ final String face;
+ final String message;
+ final String price;
+ final DateTime startTime;
+ final String userName;
+
+ LiveSuperChatMessage({
+ required this.backgroundBottomColor,
+ required this.backgroundColor,
+ required this.endTime,
+ required this.face,
+ required this.message,
+ required this.price,
+ required this.startTime,
+ required this.userName,
+ });
+}
+
+enum LiveMessageType {
+ // 普通留言
+ chat,
+ // 醒目留言
+ superChat,
+ //
+ online,
+ // 加入
+ join,
+ // 关注
+ follow,
+}
+
+class LiveMessageColor {
+ final int r, g, b;
+ LiveMessageColor(this.r, this.g, this.b);
+ static LiveMessageColor get white => LiveMessageColor(255, 255, 255);
+ static LiveMessageColor numberToColor(int intColor) {
+ var obj = intColor.toRadixString(16);
+
+ LiveMessageColor color = LiveMessageColor.white;
+ if (obj.length == 4) {
+ obj = "00$obj";
+ }
+ if (obj.length == 6) {
+ var R = int.parse(obj.substring(0, 2), radix: 16);
+ var G = int.parse(obj.substring(2, 4), radix: 16);
+ var B = int.parse(obj.substring(4, 6), radix: 16);
+
+ color = LiveMessageColor(R, G, B);
+ }
+ if (obj.length == 8) {
+ var R = int.parse(obj.substring(2, 4), radix: 16);
+ var G = int.parse(obj.substring(4, 6), radix: 16);
+ var B = int.parse(obj.substring(6, 8), radix: 16);
+ //var A = int.parse(obj.substring(0, 2), radix: 16);
+ color = LiveMessageColor(R, G, B);
+ }
+
+ return color;
+ }
+
+ @override
+ String toString() {
+ return "#${r.toRadixString(16).padLeft(2, '0')}${g.toRadixString(16).padLeft(2, '0')}${b.toRadixString(16).padLeft(2, '0')}";
+ }
+}
diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart
index 4e67fa2c..fa95ce63 100644
--- a/lib/pages/live_room/controller.dart
+++ b/lib/pages/live_room/controller.dart
@@ -1,10 +1,16 @@
+import 'dart:convert';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
+import 'package:hive/hive.dart';
import 'package:pilipala/http/constants.dart';
+import 'package:pilipala/http/init.dart';
import 'package:pilipala/http/live.dart';
+import 'package:pilipala/models/live/message.dart';
import 'package:pilipala/models/live/quality.dart';
import 'package:pilipala/models/live/room_info.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
+import 'package:pilipala/plugin/pl_socket/index.dart';
+import 'package:pilipala/utils/live.dart';
import '../../models/live/room_info_h5.dart';
import '../../utils/storage.dart';
import '../../utils/video_utils.dart';
@@ -24,6 +30,13 @@ class LiveRoomController extends GetxController {
int? tempCurrentQn;
late List