Compare commits

..

2 Commits

Author SHA1 Message Date
d003f864ce feat: 订阅取消 issues #658 2024-03-30 17:01:32 +08:00
dd7b226351 Merge branch 'main' into feature-subscription 2024-03-30 16:40:10 +08:00
8 changed files with 115 additions and 47 deletions

View File

@ -506,4 +506,6 @@ class Api {
/// 排行榜 /// 排行榜
static const String getRankApi = "/x/web-interface/ranking/v2"; static const String getRankApi = "/x/web-interface/ranking/v2";
/// 取消订阅
static const String cancelSub = '/x/v3/fav/season/unfav';
} }

View File

@ -349,4 +349,21 @@ class UserHttp {
return {'status': false, 'msg': res.data['message']}; return {'status': false, 'msg': res.data['message']};
} }
} }
// 取消订阅
static Future cancelSub({required int seasonId}) async {
var res = await Request().post(
Api.cancelSub,
queryParameters: {
'platform': 'web',
'season_id': seasonId,
'csrf': await Request.getCsrf(),
},
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
} }

View File

@ -46,4 +46,40 @@ class SubController extends GetxController {
Future onLoad() async { Future onLoad() async {
querySubFolder(type: 'onload'); querySubFolder(type: 'onload');
} }
// 取消订阅
Future<void> cancelSub(SubFolderItemData subFolderItem) async {
showDialog(
context: Get.context!,
builder: (context) => AlertDialog(
title: const Text('提示'),
content: const Text('确定取消订阅吗?'),
actions: [
TextButton(
onPressed: () {
Get.back();
},
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
var res = await UserHttp.cancelSub(seasonId: subFolderItem.id!);
if (res['status']) {
subFolderData.value.list!.remove(subFolderItem);
subFolderData.update((val) {});
SmartDialog.showToast('取消订阅成功');
} else {
SmartDialog.showToast(res['msg']);
}
Get.back();
},
child: const Text('确定'),
),
],
),
);
}
} }

View File

@ -58,7 +58,8 @@ class _SubPageState extends State<SubPage> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
return SubItem( return SubItem(
subFolderItem: subFolderItem:
_subController.subFolderData.value.list![index]); _subController.subFolderData.value.list![index],
cancelSub: _subController.cancelSub);
}, },
), ),
); );

View File

@ -8,7 +8,12 @@ import '../../../models/user/sub_folder.dart';
class SubItem extends StatelessWidget { class SubItem extends StatelessWidget {
final SubFolderItemData subFolderItem; final SubFolderItemData subFolderItem;
const SubItem({super.key, required this.subFolderItem}); final Function(SubFolderItemData) cancelSub;
const SubItem({
super.key,
required this.subFolderItem,
required this.cancelSub,
});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -51,7 +56,10 @@ class SubItem extends StatelessWidget {
}, },
), ),
), ),
VideoContent(subFolderItem: subFolderItem) VideoContent(
subFolderItem: subFolderItem,
cancelSub: cancelSub,
)
], ],
), ),
); );
@ -64,7 +72,8 @@ class SubItem extends StatelessWidget {
class VideoContent extends StatelessWidget { class VideoContent extends StatelessWidget {
final SubFolderItemData subFolderItem; final SubFolderItemData subFolderItem;
const VideoContent({super.key, required this.subFolderItem}); final Function(SubFolderItemData)? cancelSub;
const VideoContent({super.key, required this.subFolderItem, this.cancelSub});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -100,6 +109,24 @@ class VideoContent extends StatelessWidget {
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,
), ),
), ),
const Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
height: 35,
width: 35,
child: IconButton(
onPressed: () => cancelSub?.call(subFolderItem),
style: TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.outline,
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
),
icon: const Icon(Icons.delete_outline, size: 18),
),
)
],
)
], ],
), ),
), ),

View File

@ -393,13 +393,7 @@ class PlPlayerController {
} }
// 配置Player 音轨、字幕等等 // 配置Player 音轨、字幕等等
_videoPlayerController = await _createVideoController( _videoPlayerController = await _createVideoController(
dataSource, dataSource, _looping, enableHA, width, height);
_looping,
enableHA,
width,
height,
seekTo,
);
// 获取视频时长 00:00 // 获取视频时长 00:00
_duration.value = duration ?? _videoPlayerController!.state.duration; _duration.value = duration ?? _videoPlayerController!.state.duration;
updateDurationSecond(); updateDurationSecond();
@ -410,7 +404,7 @@ class PlPlayerController {
if (!_listenersInitialized) { if (!_listenersInitialized) {
startListeners(); startListeners();
} }
await _initializePlayer(duration: _duration.value); await _initializePlayer(seekTo: seekTo, duration: _duration.value);
bool autoEnterFullcreen = bool autoEnterFullcreen =
setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false); setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false);
if (autoEnterFullcreen && _isFirstTime) { if (autoEnterFullcreen && _isFirstTime) {
@ -430,7 +424,6 @@ class PlPlayerController {
bool enableHA, bool enableHA,
double? width, double? width,
double? height, double? height,
Duration? seekTo,
) async { ) async {
// 每次配置时先移除监听 // 每次配置时先移除监听
removeListeners(); removeListeners();
@ -513,11 +506,7 @@ class PlPlayerController {
); );
} }
player.open( player.open(
Media( Media(dataSource.videoSource!, httpHeaders: dataSource.httpHeaders),
dataSource.videoSource!,
httpHeaders: dataSource.httpHeaders,
start: seekTo ?? Duration.zero,
),
play: false, play: false,
); );
// 音轨 // 音轨
@ -530,6 +519,7 @@ class PlPlayerController {
// 开始播放 // 开始播放
Future _initializePlayer({ Future _initializePlayer({
Duration seekTo = Duration.zero,
Duration? duration, Duration? duration,
}) async { }) async {
// 设置倍速 // 设置倍速
@ -547,6 +537,11 @@ class PlPlayerController {
// await setLooping(_looping); // await setLooping(_looping);
// } // }
// 跳转播放
if (seekTo != Duration.zero) {
await this.seekTo(seekTo);
}
// 自动播放 // 自动播放
if (_autoPlay) { if (_autoPlay) {
await play(duration: duration); await play(duration: duration);
@ -666,14 +661,21 @@ class PlPlayerController {
await _videoPlayerController?.stream.buffer.first; await _videoPlayerController?.stream.buffer.first;
} }
await _videoPlayerController?.seek(position); await _videoPlayerController?.seek(position);
// if (playerStatus.stopped) {
// play();
// }
} else { } else {
print('seek duration else'); print('seek duration else');
_timerForSeek?.cancel(); _timerForSeek?.cancel();
_timerForSeek = _timerForSeek =
Timer.periodic(const Duration(milliseconds: 200), (Timer t) async { Timer.periodic(const Duration(milliseconds: 200), (Timer t) async {
//_timerForSeek = null;
if (duration.value.inSeconds != 0) { if (duration.value.inSeconds != 0) {
await _videoPlayerController!.stream.buffer.first; await _videoPlayerController!.stream.buffer.first;
await _videoPlayerController?.seek(position); await _videoPlayerController?.seek(position);
// if (playerStatus.status.value == PlayerStatus.paused) {
// play();
// }
t.cancel(); t.cancel();
_timerForSeek = null; _timerForSeek = null;
} }

View File

@ -865,11 +865,10 @@ packages:
media_kit: media_kit:
dependency: "direct main" dependency: "direct main"
description: description:
path: media_kit name: media_kit
ref: HEAD sha256: "3289062540e3b8b9746e5c50d95bd78a9289826b7227e253dff806d002b9e67a"
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0" url: "https://pub.flutter-io.cn"
url: "https://github.com/media-kit/media-kit.git" source: hosted
source: git
version: "1.1.10+1" version: "1.1.10+1"
media_kit_libs_android_video: media_kit_libs_android_video:
dependency: transitive dependency: transitive
@ -906,11 +905,10 @@ packages:
media_kit_libs_video: media_kit_libs_video:
dependency: "direct main" dependency: "direct main"
description: description:
path: "libs/universal/media_kit_libs_video" name: media_kit_libs_video
ref: HEAD sha256: "3688e0c31482074578652bf038ce6301a5d21e1eda6b54fc3117ffeb4bdba067"
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0" url: "https://pub.flutter-io.cn"
url: "https://github.com/media-kit/media-kit.git" source: hosted
source: git
version: "1.0.4" version: "1.0.4"
media_kit_libs_windows_video: media_kit_libs_windows_video:
dependency: transitive dependency: transitive
@ -931,11 +929,10 @@ packages:
media_kit_video: media_kit_video:
dependency: "direct main" dependency: "direct main"
description: description:
path: media_kit_video name: media_kit_video
ref: HEAD sha256: c048d11a19e379aebbe810647636e3fc6d18374637e2ae12def4ff8a4b99a882
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0" url: "https://pub.flutter-io.cn"
url: "https://github.com/media-kit/media-kit.git" source: hosted
source: git
version: "1.2.4" version: "1.2.4"
meta: meta:
dependency: transitive dependency: transitive

View File

@ -163,20 +163,6 @@ dev_dependencies:
hive_generator: ^2.0.0 hive_generator: ^2.0.0
build_runner: ^2.4.8 build_runner: ^2.4.8
dependency_overrides:
media_kit:
git:
url: https://github.com/media-kit/media-kit.git
path: media_kit
media_kit_video:
git:
url: https://github.com/media-kit/media-kit.git
path: media_kit_video
media_kit_libs_video:
git:
url: https://github.com/media-kit/media-kit.git
path: libs/universal/media_kit_libs_video
flutter_launcher_icons: flutter_launcher_icons:
android: true android: true
ios: true ios: true