mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-27 13:55:54 +08:00
@@ -5,15 +5,17 @@ import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/live.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/common/video/live_quality.dart';
|
||||
import 'package:PiliPlus/models/live/live_room/danmu_info.dart';
|
||||
import 'package:PiliPlus/models/live/live_room/room_info.dart';
|
||||
import 'package:PiliPlus/models/live/live_room/room_info_h5.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_dm_info/data.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_room_info_h5/data.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_room_play_info/codec.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_room_play_info/data.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/data_source.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
import 'package:PiliPlus/tcp/live.dart';
|
||||
import 'package:PiliPlus/utils/danmaku_utils.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/video_utils.dart';
|
||||
import 'package:canvas_danmaku/canvas_danmaku.dart';
|
||||
@@ -32,7 +34,7 @@ class LiveRoomController extends GetxController {
|
||||
RxBool volumeOff = false.obs;
|
||||
PlPlayerController plPlayerController =
|
||||
PlPlayerController.getInstance(videoType: 'live');
|
||||
Rx<RoomInfoH5Model?> roomInfoH5 = Rx<RoomInfoH5Model?>(null);
|
||||
Rx<RoomInfoH5Data?> roomInfoH5 = Rx<RoomInfoH5Data?>(null);
|
||||
|
||||
RxList<dynamic> messages = [].obs;
|
||||
RxBool disableAutoScroll = false.obs;
|
||||
@@ -58,7 +60,7 @@ class LiveRoomController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> playerInit(source) async {
|
||||
Future<void> playerInit(String source) async {
|
||||
await plPlayerController.setDataSource(
|
||||
DataSource(
|
||||
videoSource: source,
|
||||
@@ -87,7 +89,7 @@ class LiveRoomController extends GetxController {
|
||||
}
|
||||
var res = await LiveHttp.liveRoomInfo(roomId: roomId, qn: currentQn);
|
||||
if (res['status']) {
|
||||
RoomInfoModel data = res['data'];
|
||||
RoomPlayInfoData data = res['data'];
|
||||
if (data.liveStatus != 1) {
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
@@ -119,7 +121,7 @@ class LiveRoomController extends GetxController {
|
||||
currentQn = item.currentQn!;
|
||||
acceptQnList = item.acceptQn!.map((e) {
|
||||
return (
|
||||
code: e as int,
|
||||
code: e,
|
||||
desc: LiveQuality.values
|
||||
.firstWhere((element) => element.code == e)
|
||||
.description,
|
||||
@@ -183,19 +185,20 @@ class LiveRoomController extends GetxController {
|
||||
}
|
||||
});
|
||||
}
|
||||
LiveHttp.liveRoomGetDanmakuToken(roomId: roomId).then((v) {
|
||||
if (v['status']) {
|
||||
LiveDanmakuInfo info = v['data'];
|
||||
LiveHttp.liveRoomGetDanmakuToken(roomId: roomId).then((res) {
|
||||
if (res['status']) {
|
||||
LiveDmInfoData info = res['data'];
|
||||
// logger.d("info => $info");
|
||||
List<String> servers = [];
|
||||
for (final host in info.data.hostList) {
|
||||
servers.add('wss://${host.host}:${host.wssPort}/sub');
|
||||
if (info.hostList!.isNullOrEmpty) {
|
||||
return;
|
||||
}
|
||||
msgStream = LiveMessageStream(
|
||||
streamToken: info.data.token,
|
||||
streamToken: info.token!,
|
||||
roomId: roomId,
|
||||
uid: Accounts.main.mid,
|
||||
servers: servers,
|
||||
servers: info.hostList!
|
||||
.map((host) => 'wss://${host.host}:${host.wssPort}/sub')
|
||||
.toList(),
|
||||
);
|
||||
msgStream?.addEventListener((obj) {
|
||||
if (obj['cmd'] == 'DANMU_MSG') {
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'dart:ui';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
import 'package:PiliPlus/models/live/live_room/room_info_h5.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_room_info_h5/data.dart';
|
||||
import 'package:PiliPlus/pages/live_room/controller.dart';
|
||||
import 'package:PiliPlus/pages/live_room/send_danmaku/view.dart';
|
||||
import 'package:PiliPlus/pages/live_room/widgets/bottom_control.dart';
|
||||
@@ -355,110 +355,121 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
|
||||
final Color _color = const Color(0xFFEEEEEE);
|
||||
|
||||
PreferredSizeWidget get _buildAppBar => AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: Colors.white,
|
||||
toolbarHeight: isFullScreen ? 0 : null,
|
||||
titleTextStyle: const TextStyle(color: Colors.white),
|
||||
title: Obx(
|
||||
() {
|
||||
RoomInfoH5Model? roomInfoH5 = _liveRoomController.roomInfoH5.value;
|
||||
return roomInfoH5 == null
|
||||
? const SizedBox.shrink()
|
||||
: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
'/member?mid=${roomInfoH5.roomInfo?.uid}'),
|
||||
child: NetworkImgLayer(
|
||||
width: 34,
|
||||
height: 34,
|
||||
type: ImageType.avatar,
|
||||
src: roomInfoH5.anchorInfo!.baseInfo!.face,
|
||||
PreferredSizeWidget get _buildAppBar {
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: Colors.white,
|
||||
toolbarHeight: isFullScreen ? 0 : null,
|
||||
titleTextStyle: const TextStyle(color: Colors.white),
|
||||
title: Obx(
|
||||
() {
|
||||
RoomInfoH5Data? roomInfoH5 = _liveRoomController.roomInfoH5.value;
|
||||
return roomInfoH5 == null
|
||||
? const SizedBox.shrink()
|
||||
: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
'/member?mid=${roomInfoH5.roomInfo?.uid}'),
|
||||
child: NetworkImgLayer(
|
||||
width: 34,
|
||||
height: 34,
|
||||
type: ImageType.avatar,
|
||||
src: roomInfoH5.anchorInfo!.baseInfo!.face,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
roomInfoH5.anchorInfo!.baseInfo!.uname!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 1),
|
||||
if (roomInfoH5.watchedShow?.textLarge?.isNotEmpty ==
|
||||
true)
|
||||
Text(
|
||||
roomInfoH5.anchorInfo!.baseInfo!.uname!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
roomInfoH5.watchedShow!.textLarge!,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
if (roomInfoH5.watchedShow?.textLarge?.isNotEmpty ==
|
||||
true)
|
||||
Text(
|
||||
roomInfoH5.watchedShow!.textLarge!,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: '刷新',
|
||||
onPressed: () =>
|
||||
_futureBuilderFuture = _liveRoomController.queryLiveInfo(),
|
||||
icon: const Icon(Icons.refresh, size: 20),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: '刷新',
|
||||
onPressed: () =>
|
||||
_futureBuilderFuture = _liveRoomController.queryLiveInfo(),
|
||||
icon: const Icon(Icons.refresh),
|
||||
),
|
||||
PopupMenuButton(
|
||||
icon: const Icon(Icons.more_vert, size: 19),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
||||
PopupMenuButton(
|
||||
icon: const Icon(Icons.more_vert, size: 20),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
||||
PopupMenuItem(
|
||||
onTap: () => PageUtils.inAppWebview(
|
||||
'https://live.bilibili.com/h5/${_liveRoomController.roomId}',
|
||||
off: true,
|
||||
),
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.open_in_browser,
|
||||
size: 19,
|
||||
color: color,
|
||||
),
|
||||
const Text('浏览器打开'),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_liveRoomController.roomInfoH5.value != null)
|
||||
PopupMenuItem(
|
||||
onTap: () => PageUtils.inAppWebview(
|
||||
'https://live.bilibili.com/h5/${_liveRoomController.roomId}',
|
||||
off: true,
|
||||
),
|
||||
child: const Row(
|
||||
onTap: () {
|
||||
try {
|
||||
RoomInfoH5Data roomInfo =
|
||||
_liveRoomController.roomInfoH5.value!;
|
||||
PageUtils.pmShare(
|
||||
this.context,
|
||||
content: {
|
||||
"cover": roomInfo.roomInfo!.cover!,
|
||||
"sourceID": _liveRoomController.roomId.toString(),
|
||||
"title": roomInfo.roomInfo!.title!,
|
||||
"url":
|
||||
"https://live.bilibili.com/${_liveRoomController.roomId}",
|
||||
"authorID": roomInfo.roomInfo!.uid.toString(),
|
||||
"source": "直播",
|
||||
"desc": roomInfo.roomInfo!.title!,
|
||||
"author": roomInfo.anchorInfo!.baseInfo!.uname,
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.open_in_browser, size: 19),
|
||||
SizedBox(width: 10),
|
||||
Text('浏览器打开'),
|
||||
Icon(
|
||||
Icons.forward_to_inbox,
|
||||
size: 19,
|
||||
color: color,
|
||||
),
|
||||
const Text('分享至消息'),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_liveRoomController.roomInfoH5.value != null)
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
try {
|
||||
RoomInfoH5Model roomInfo =
|
||||
_liveRoomController.roomInfoH5.value!;
|
||||
PageUtils.pmShare(
|
||||
this.context,
|
||||
content: {
|
||||
"cover": roomInfo.roomInfo!.cover!,
|
||||
"sourceID": _liveRoomController.roomId.toString(),
|
||||
"title": roomInfo.roomInfo!.title!,
|
||||
"url":
|
||||
"https://live.bilibili.com/${_liveRoomController.roomId}",
|
||||
"authorID": roomInfo.roomInfo!.uid.toString(),
|
||||
"source": "直播",
|
||||
"desc": roomInfo.roomInfo!.title!,
|
||||
"author": roomInfo.anchorInfo!.baseInfo!.uname,
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.forward_to_inbox, size: 19),
|
||||
SizedBox(width: 10),
|
||||
Text('分享至消息'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget get _buildBodyH {
|
||||
double videoWidth =
|
||||
|
||||
Reference in New Issue
Block a user