mod: 默认直播画质设置

This commit is contained in:
guozhigq
2024-03-13 23:12:34 +08:00
parent 98aaca286b
commit da2bbeedff
5 changed files with 62 additions and 31 deletions

View File

@ -2,7 +2,6 @@ enum LiveQuality {
dolby, dolby,
super4K, super4K,
origin, origin,
veryHigh,
bluRay, bluRay,
superHD, superHD,
smooth, smooth,
@ -37,6 +36,7 @@ extension VideoQualityDesc on LiveQuality {
'原画', '原画',
'蓝光', '蓝光',
'超清', '超清',
'高清',
'流畅', '流畅',
]; ];
get description => _descList[index]; get description => _descList[index];

View File

@ -27,7 +27,8 @@ class LiveRoomController extends GetxController {
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
currentQn = 10000; currentQn = setting.get(SettingBoxKey.defaultLiveQa,
defaultValue: LiveQuality.values.last.code);
roomId = int.parse(Get.parameters['roomid']!); roomId = int.parse(Get.parameters['roomid']!);
if (Get.arguments != null) { if (Get.arguments != null) {
liveItem = Get.arguments['liveItem']; liveItem = Get.arguments['liveItem'];
@ -62,7 +63,6 @@ class LiveRoomController extends GetxController {
} }
Future queryLiveInfo() async { Future queryLiveInfo() async {
/// TODO 默认获取预设质量的直播资源
var res = await LiveHttp.liveRoomInfo(roomId: roomId, qn: currentQn); var res = await LiveHttp.liveRoomInfo(roomId: roomId, qn: currentQn);
if (res['status']) { if (res['status']) {
List<CodecItem> codec = List<CodecItem> codec =

View File

@ -85,6 +85,30 @@ class _BottomControlState extends State<BottomControl> {
// ), // ),
// ), // ),
// const SizedBox(width: 4), // const SizedBox(width: 4),
SizedBox(
width: 30,
child: PopupMenuButton<int>(
padding: EdgeInsets.zero,
onSelected: (value) {
widget.liveRoomCtr!.changeQn(value);
},
child: Obx(
() => Text(
widget.liveRoomCtr!.currentQnDesc.value,
style: const TextStyle(color: Colors.white, fontSize: 13),
),
),
itemBuilder: (BuildContext context) {
return widget.liveRoomCtr!.acceptQnList.map((e) {
return PopupMenuItem<int>(
value: e['code'],
child: Text(e['desc']),
);
}).toList();
},
),
),
const SizedBox(width: 10),
if (Platform.isAndroid) ...[ if (Platform.isAndroid) ...[
SizedBox( SizedBox(
width: 34, width: 34,
@ -112,32 +136,8 @@ class _BottomControlState extends State<BottomControl> {
), ),
), ),
), ),
const SizedBox(width: 4),
],
SizedBox(
width: 30,
child: PopupMenuButton<int>(
padding: EdgeInsets.zero,
onSelected: (value) {
widget.liveRoomCtr!.changeQn(value);
},
child: Obx(
() => Text(
widget.liveRoomCtr!.currentQnDesc.value,
style: const TextStyle(color: Colors.white, fontSize: 13),
),
),
itemBuilder: (BuildContext context) {
return widget.liveRoomCtr!.acceptQnList.map((e) {
return PopupMenuItem<int>(
value: e['code'],
child: Text(e['desc']),
);
}).toList();
},
),
),
const SizedBox(width: 10), const SizedBox(width: 10),
],
ComBtn( ComBtn(
icon: const Icon( icon: const Icon(
Icons.fullscreen, Icons.fullscreen,

View File

@ -9,6 +9,7 @@ import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/services/service_locator.dart'; import 'package:pilipala/services/service_locator.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
import '../../models/live/quality.dart';
import 'widgets/switch_item.dart'; import 'widgets/switch_item.dart';
class PlaySetting extends StatefulWidget { class PlaySetting extends StatefulWidget {
@ -21,6 +22,7 @@ class PlaySetting extends StatefulWidget {
class _PlaySettingState extends State<PlaySetting> { class _PlaySettingState extends State<PlaySetting> {
Box setting = GStrorage.setting; Box setting = GStrorage.setting;
late dynamic defaultVideoQa; late dynamic defaultVideoQa;
late dynamic defaultLiveQa;
late dynamic defaultAudioQa; late dynamic defaultAudioQa;
late dynamic defaultDecode; late dynamic defaultDecode;
late int defaultFullScreenMode; late int defaultFullScreenMode;
@ -31,6 +33,8 @@ class _PlaySettingState extends State<PlaySetting> {
super.initState(); super.initState();
defaultVideoQa = setting.get(SettingBoxKey.defaultVideoQa, defaultVideoQa = setting.get(SettingBoxKey.defaultVideoQa,
defaultValue: VideoQuality.values.last.code); defaultValue: VideoQuality.values.last.code);
defaultLiveQa = setting.get(SettingBoxKey.defaultLiveQa,
defaultValue: LiveQuality.values.last.code);
defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa, defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
defaultValue: AudioQuality.values.last.code); defaultValue: AudioQuality.values.last.code);
defaultDecode = setting.get(SettingBoxKey.defaultDecode, defaultDecode = setting.get(SettingBoxKey.defaultDecode,
@ -148,9 +152,9 @@ class _PlaySettingState extends State<PlaySetting> {
), ),
ListTile( ListTile(
dense: false, dense: false,
title: Text('默认画质', style: titleStyle), title: Text('默认视频画质', style: titleStyle),
subtitle: Text( subtitle: Text(
'当前画质${VideoQualityCode.fromCode(defaultVideoQa)!.description!}', '当前默认画质${VideoQualityCode.fromCode(defaultVideoQa)!.description!}',
style: subTitleStyle, style: subTitleStyle,
), ),
onTap: () async { onTap: () async {
@ -158,7 +162,7 @@ class _PlaySettingState extends State<PlaySetting> {
context: context, context: context,
builder: (context) { builder: (context) {
return SelectDialog<int>( return SelectDialog<int>(
title: '默认画质', title: '默认视频画质',
value: defaultVideoQa, value: defaultVideoQa,
values: VideoQuality.values.reversed.map((e) { values: VideoQuality.values.reversed.map((e) {
return {'title': e.description, 'value': e.code}; return {'title': e.description, 'value': e.code};
@ -172,6 +176,32 @@ class _PlaySettingState extends State<PlaySetting> {
} }
}, },
), ),
ListTile(
dense: false,
title: Text('默认直播画质', style: titleStyle),
subtitle: Text(
'当前默认画质${LiveQualityCode.fromCode(defaultLiveQa)!.description!}',
style: subTitleStyle,
),
onTap: () async {
int? result = await showDialog(
context: context,
builder: (context) {
return SelectDialog<int>(
title: '默认直播画质',
value: defaultLiveQa,
values: LiveQuality.values.reversed.map((e) {
return {'title': e.description, 'value': e.code};
}).toList());
},
);
if (result != null) {
defaultLiveQa = result;
setting.put(SettingBoxKey.defaultLiveQa, result);
setState(() {});
}
},
),
ListTile( ListTile(
dense: false, dense: false,
title: Text('默认音质', style: titleStyle), title: Text('默认音质', style: titleStyle),

View File

@ -77,6 +77,7 @@ class SettingBoxKey {
autoUpgradeEnable = 'autoUpgradeEnable', autoUpgradeEnable = 'autoUpgradeEnable',
feedBackEnable = 'feedBackEnable', feedBackEnable = 'feedBackEnable',
defaultVideoQa = 'defaultVideoQa', defaultVideoQa = 'defaultVideoQa',
defaultLiveQa = 'defaultLiveQa',
defaultAudioQa = 'defaultAudioQa', defaultAudioQa = 'defaultAudioQa',
autoPlayEnable = 'autoPlayEnable', autoPlayEnable = 'autoPlayEnable',
fullScreenMode = 'fullScreenMode', fullScreenMode = 'fullScreenMode',