mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
custom audio order
Closes #1636 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -44,6 +44,7 @@ class AudioGrpc {
|
||||
String? next,
|
||||
int qn = 80,
|
||||
int fnval = 4048,
|
||||
ListOrder order = ListOrder.ORDER_NORMAL,
|
||||
}) {
|
||||
return GrpcReq.request(
|
||||
GrpcUrl.audioPlayList,
|
||||
@@ -63,7 +64,7 @@ class AudioGrpc {
|
||||
voiceBalance: Int64(1),
|
||||
),
|
||||
extraId: extraId,
|
||||
sortOpt: SortOption(order: ListOrder.ORDER_NORMAL),
|
||||
sortOpt: SortOption(order: order),
|
||||
pagination: Pagination(pageSize: 20, next: next),
|
||||
),
|
||||
PlaylistResp.fromBuffer,
|
||||
|
||||
@@ -9,7 +9,8 @@ import 'package:PiliPlus/grpc/bilibili/app/listener/v1.pb.dart'
|
||||
PlaylistResp,
|
||||
PlaylistSource,
|
||||
PlayInfo,
|
||||
ThumbUpReq_ThumbType;
|
||||
ThumbUpReq_ThumbType,
|
||||
ListOrder;
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/ua_type.dart';
|
||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart'
|
||||
@@ -78,6 +79,8 @@ class AudioController extends GetxController
|
||||
String? _next;
|
||||
bool get reachStart => _prev == null;
|
||||
|
||||
ListOrder order = ListOrder.ORDER_NORMAL;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -163,6 +166,7 @@ class AudioController extends GetxController
|
||||
? _next
|
||||
: null,
|
||||
extraId: extraId,
|
||||
order: order,
|
||||
);
|
||||
if (res.isSuccess) {
|
||||
final PlaylistResp data = res.data;
|
||||
@@ -576,6 +580,9 @@ class AudioController extends GetxController
|
||||
if (index != null && playlist != null && player != null) {
|
||||
final next = index! + 1;
|
||||
if (next < playlist!.length) {
|
||||
if (next == playlist!.length - 1 && _next != null) {
|
||||
_queryPlayList(isLoadNext: true);
|
||||
}
|
||||
playIndex(next);
|
||||
return true;
|
||||
}
|
||||
@@ -644,6 +651,13 @@ class AudioController extends GetxController
|
||||
}
|
||||
}
|
||||
|
||||
void onChangeOrder(ListOrder value) {
|
||||
if (order != value) {
|
||||
order = value;
|
||||
_queryPlayList(isInit: true);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// _cancelTimer();
|
||||
|
||||
@@ -56,6 +56,10 @@ class AudioPage extends StatefulWidget {
|
||||
);
|
||||
}
|
||||
|
||||
extension _ListOrderExt on ListOrder {
|
||||
String get title => const ['无序', '正序', '倒序', '随机'][value];
|
||||
}
|
||||
|
||||
class _AudioPageState extends State<AudioPage> {
|
||||
final _controller = Get.put(
|
||||
AudioController(),
|
||||
@@ -75,15 +79,30 @@ class _AudioPageState extends State<AudioPage> {
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
actions: _controller.isVideo
|
||||
? [
|
||||
IconButton(
|
||||
onPressed: _showMore,
|
||||
icon: const Icon(Icons.more_vert),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
]
|
||||
: null,
|
||||
actions: [
|
||||
Builder(
|
||||
builder: (context) {
|
||||
return PopupMenuButton<ListOrder>(
|
||||
tooltip: '排序',
|
||||
icon: const Icon(Icons.sort),
|
||||
initialValue: _controller.order,
|
||||
onSelected: (value) {
|
||||
_controller.onChangeOrder(value);
|
||||
(context as Element).markNeedsBuild();
|
||||
},
|
||||
itemBuilder: (context) => ListOrder.values
|
||||
.map((e) => PopupMenuItem(value: e, child: Text(e.title)))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (_controller.isVideo)
|
||||
IconButton(
|
||||
onPressed: _showMore,
|
||||
icon: const Icon(Icons.more_vert),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
|
||||
Reference in New Issue
Block a user