mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 16:48:16 +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,
|
String? next,
|
||||||
int qn = 80,
|
int qn = 80,
|
||||||
int fnval = 4048,
|
int fnval = 4048,
|
||||||
|
ListOrder order = ListOrder.ORDER_NORMAL,
|
||||||
}) {
|
}) {
|
||||||
return GrpcReq.request(
|
return GrpcReq.request(
|
||||||
GrpcUrl.audioPlayList,
|
GrpcUrl.audioPlayList,
|
||||||
@@ -63,7 +64,7 @@ class AudioGrpc {
|
|||||||
voiceBalance: Int64(1),
|
voiceBalance: Int64(1),
|
||||||
),
|
),
|
||||||
extraId: extraId,
|
extraId: extraId,
|
||||||
sortOpt: SortOption(order: ListOrder.ORDER_NORMAL),
|
sortOpt: SortOption(order: order),
|
||||||
pagination: Pagination(pageSize: 20, next: next),
|
pagination: Pagination(pageSize: 20, next: next),
|
||||||
),
|
),
|
||||||
PlaylistResp.fromBuffer,
|
PlaylistResp.fromBuffer,
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import 'package:PiliPlus/grpc/bilibili/app/listener/v1.pb.dart'
|
|||||||
PlaylistResp,
|
PlaylistResp,
|
||||||
PlaylistSource,
|
PlaylistSource,
|
||||||
PlayInfo,
|
PlayInfo,
|
||||||
ThumbUpReq_ThumbType;
|
ThumbUpReq_ThumbType,
|
||||||
|
ListOrder;
|
||||||
import 'package:PiliPlus/http/constants.dart';
|
import 'package:PiliPlus/http/constants.dart';
|
||||||
import 'package:PiliPlus/http/ua_type.dart';
|
import 'package:PiliPlus/http/ua_type.dart';
|
||||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart'
|
import 'package:PiliPlus/pages/common/common_intro_controller.dart'
|
||||||
@@ -78,6 +79,8 @@ class AudioController extends GetxController
|
|||||||
String? _next;
|
String? _next;
|
||||||
bool get reachStart => _prev == null;
|
bool get reachStart => _prev == null;
|
||||||
|
|
||||||
|
ListOrder order = ListOrder.ORDER_NORMAL;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -163,6 +166,7 @@ class AudioController extends GetxController
|
|||||||
? _next
|
? _next
|
||||||
: null,
|
: null,
|
||||||
extraId: extraId,
|
extraId: extraId,
|
||||||
|
order: order,
|
||||||
);
|
);
|
||||||
if (res.isSuccess) {
|
if (res.isSuccess) {
|
||||||
final PlaylistResp data = res.data;
|
final PlaylistResp data = res.data;
|
||||||
@@ -576,6 +580,9 @@ class AudioController extends GetxController
|
|||||||
if (index != null && playlist != null && player != null) {
|
if (index != null && playlist != null && player != null) {
|
||||||
final next = index! + 1;
|
final next = index! + 1;
|
||||||
if (next < playlist!.length) {
|
if (next < playlist!.length) {
|
||||||
|
if (next == playlist!.length - 1 && _next != null) {
|
||||||
|
_queryPlayList(isLoadNext: true);
|
||||||
|
}
|
||||||
playIndex(next);
|
playIndex(next);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -644,6 +651,13 @@ class AudioController extends GetxController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onChangeOrder(ListOrder value) {
|
||||||
|
if (order != value) {
|
||||||
|
order = value;
|
||||||
|
_queryPlayList(isInit: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
// _cancelTimer();
|
// _cancelTimer();
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ class AudioPage extends StatefulWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension _ListOrderExt on ListOrder {
|
||||||
|
String get title => const ['无序', '正序', '倒序', '随机'][value];
|
||||||
|
}
|
||||||
|
|
||||||
class _AudioPageState extends State<AudioPage> {
|
class _AudioPageState extends State<AudioPage> {
|
||||||
final _controller = Get.put(
|
final _controller = Get.put(
|
||||||
AudioController(),
|
AudioController(),
|
||||||
@@ -75,15 +79,30 @@ class _AudioPageState extends State<AudioPage> {
|
|||||||
final padding = MediaQuery.viewPaddingOf(context);
|
final padding = MediaQuery.viewPaddingOf(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
actions: _controller.isVideo
|
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(
|
IconButton(
|
||||||
onPressed: _showMore,
|
onPressed: _showMore,
|
||||||
icon: const Icon(Icons.more_vert),
|
icon: const Icon(Icons.more_vert),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
const SizedBox(width: 5),
|
||||||
]
|
],
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
|
|||||||
Reference in New Issue
Block a user