diff --git a/lib/models/live/quality.dart b/lib/models/live/quality.dart index 47938416..677d615b 100644 --- a/lib/models/live/quality.dart +++ b/lib/models/live/quality.dart @@ -2,7 +2,6 @@ enum LiveQuality { dolby, super4K, origin, - veryHigh, bluRay, superHD, smooth, @@ -37,6 +36,7 @@ extension VideoQualityDesc on LiveQuality { '原画', '蓝光', '超清', + '高清', '流畅', ]; get description => _descList[index]; diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index a1878c74..f785da63 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -27,7 +27,8 @@ class LiveRoomController extends GetxController { @override void onInit() { super.onInit(); - currentQn = 10000; + currentQn = setting.get(SettingBoxKey.defaultLiveQa, + defaultValue: LiveQuality.values.last.code); roomId = int.parse(Get.parameters['roomid']!); if (Get.arguments != null) { liveItem = Get.arguments['liveItem']; @@ -62,7 +63,6 @@ class LiveRoomController extends GetxController { } Future queryLiveInfo() async { - /// TODO 默认获取预设质量的直播资源 var res = await LiveHttp.liveRoomInfo(roomId: roomId, qn: currentQn); if (res['status']) { List codec = diff --git a/lib/pages/live_room/widgets/bottom_control.dart b/lib/pages/live_room/widgets/bottom_control.dart index 0dcedc2c..c98a80ae 100644 --- a/lib/pages/live_room/widgets/bottom_control.dart +++ b/lib/pages/live_room/widgets/bottom_control.dart @@ -85,6 +85,30 @@ class _BottomControlState extends State { // ), // ), // const SizedBox(width: 4), + SizedBox( + width: 30, + child: PopupMenuButton( + 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( + value: e['code'], + child: Text(e['desc']), + ); + }).toList(); + }, + ), + ), + const SizedBox(width: 10), if (Platform.isAndroid) ...[ SizedBox( width: 34, @@ -112,32 +136,8 @@ class _BottomControlState extends State { ), ), ), - const SizedBox(width: 4), + const SizedBox(width: 10), ], - SizedBox( - width: 30, - child: PopupMenuButton( - 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( - value: e['code'], - child: Text(e['desc']), - ); - }).toList(); - }, - ), - ), - const SizedBox(width: 10), ComBtn( icon: const Icon( Icons.fullscreen, diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index bfd5db5f..03e91212 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -9,6 +9,7 @@ import 'package:pilipala/plugin/pl_player/index.dart'; import 'package:pilipala/services/service_locator.dart'; import 'package:pilipala/utils/storage.dart'; +import '../../models/live/quality.dart'; import 'widgets/switch_item.dart'; class PlaySetting extends StatefulWidget { @@ -21,6 +22,7 @@ class PlaySetting extends StatefulWidget { class _PlaySettingState extends State { Box setting = GStrorage.setting; late dynamic defaultVideoQa; + late dynamic defaultLiveQa; late dynamic defaultAudioQa; late dynamic defaultDecode; late int defaultFullScreenMode; @@ -31,6 +33,8 @@ class _PlaySettingState extends State { super.initState(); defaultVideoQa = setting.get(SettingBoxKey.defaultVideoQa, defaultValue: VideoQuality.values.last.code); + defaultLiveQa = setting.get(SettingBoxKey.defaultLiveQa, + defaultValue: LiveQuality.values.last.code); defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa, defaultValue: AudioQuality.values.last.code); defaultDecode = setting.get(SettingBoxKey.defaultDecode, @@ -148,9 +152,9 @@ class _PlaySettingState extends State { ), ListTile( dense: false, - title: Text('默认画质', style: titleStyle), + title: Text('默认视频画质', style: titleStyle), subtitle: Text( - '当前画质${VideoQualityCode.fromCode(defaultVideoQa)!.description!}', + '当前默认画质${VideoQualityCode.fromCode(defaultVideoQa)!.description!}', style: subTitleStyle, ), onTap: () async { @@ -158,7 +162,7 @@ class _PlaySettingState extends State { context: context, builder: (context) { return SelectDialog( - title: '默认画质', + title: '默认视频画质', value: defaultVideoQa, values: VideoQuality.values.reversed.map((e) { return {'title': e.description, 'value': e.code}; @@ -172,6 +176,32 @@ class _PlaySettingState extends State { } }, ), + 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( + 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( dense: false, title: Text('默认音质', style: titleStyle), diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 16cef463..47fd7596 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -77,6 +77,7 @@ class SettingBoxKey { autoUpgradeEnable = 'autoUpgradeEnable', feedBackEnable = 'feedBackEnable', defaultVideoQa = 'defaultVideoQa', + defaultLiveQa = 'defaultLiveQa', defaultAudioQa = 'defaultAudioQa', autoPlayEnable = 'autoPlayEnable', fullScreenMode = 'fullScreenMode',