mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-16 06:03:54 +08:00
prefetch fav video intro
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -80,10 +80,14 @@ abstract class CommonIntroController extends GetxController
|
|||||||
cid = RxInt(args['cid']);
|
cid = RxInt(args['cid']);
|
||||||
hasLater.value = args['sourceType'] == SourceType.watchLater;
|
hasLater.value = args['sourceType'] == SourceType.watchLater;
|
||||||
|
|
||||||
queryVideoIntro();
|
initQueryVideoIntro(args);
|
||||||
startTimer();
|
startTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initQueryVideoIntro(Map args) {
|
||||||
|
queryVideoIntro();
|
||||||
|
}
|
||||||
|
|
||||||
void startTimer() {
|
void startTimer() {
|
||||||
if (isShowOnlineTotal) {
|
if (isShowOnlineTotal) {
|
||||||
queryOnlineTotal();
|
queryOnlineTotal();
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||||
import 'package:PiliPlus/http/fav.dart';
|
import 'package:PiliPlus/http/fav.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:PiliPlus/http/video.dart';
|
||||||
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
||||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||||
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
||||||
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
||||||
import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
||||||
|
import 'package:PiliPlus/models_new/video/video_detail/data.dart';
|
||||||
|
import 'package:PiliPlus/models_new/video/video_detail/page.dart';
|
||||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||||
import 'package:PiliPlus/pages/common/multi_select/base.dart';
|
import 'package:PiliPlus/pages/common/multi_select/base.dart';
|
||||||
import 'package:PiliPlus/pages/common/multi_select/multi_select_controller.dart';
|
import 'package:PiliPlus/pages/common/multi_select/multi_select_controller.dart';
|
||||||
@@ -16,6 +19,7 @@ import 'package:PiliPlus/utils/page_utils.dart';
|
|||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:PiliPlus/utils/storage_key.dart';
|
import 'package:PiliPlus/utils/storage_key.dart';
|
||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/widgets.dart' show Text, ValueChanged;
|
import 'package:flutter/widgets.dart' show Text, ValueChanged;
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -211,16 +215,25 @@ class FavDetailController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onViewFav(FavDetailItemModel item, int? index) {
|
Future<void> onViewFav(FavDetailItemModel item, int? index) async {
|
||||||
final folder = folderInfo.value;
|
final cid = item.ugc!.firstCid!;
|
||||||
// TODO: dimension
|
Part? part;
|
||||||
|
VideoDetailData? videoIntro;
|
||||||
|
final res = await VideoHttp.videoIntro(bvid: item.bvid!);
|
||||||
|
if (res case Success(:final response)) {
|
||||||
|
videoIntro = response;
|
||||||
|
part = response.pages?.firstWhereOrNull((e) => e.cid == cid);
|
||||||
|
}
|
||||||
|
late final folder = folderInfo.value;
|
||||||
PageUtils.toVideoPage(
|
PageUtils.toVideoPage(
|
||||||
bvid: item.bvid,
|
bvid: item.bvid,
|
||||||
cid: item.ugc!.firstCid!,
|
cid: cid,
|
||||||
cover: item.cover,
|
cover: item.cover,
|
||||||
title: item.title,
|
title: item.title,
|
||||||
|
dimension: part?.dimension,
|
||||||
extraArguments: isPlayAll.value
|
extraArguments: isPlayAll.value
|
||||||
? {
|
? {
|
||||||
|
'videoIntro': videoIntro,
|
||||||
'sourceType': SourceType.fav,
|
'sourceType': SourceType.fav,
|
||||||
'mediaId': folder.id,
|
'mediaId': folder.id,
|
||||||
'oid': item.id,
|
'oid': item.id,
|
||||||
@@ -230,7 +243,7 @@ class FavDetailController
|
|||||||
if (index != null) 'isContinuePlaying': index != 0,
|
if (index != null) 'isContinuePlaying': index != 0,
|
||||||
'isOwner': isOwner,
|
'isOwner': isOwner,
|
||||||
}
|
}
|
||||||
: null,
|
: {'videoIntro': videoIntro},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
import 'package:PiliPlus/http/fav.dart';
|
import 'package:PiliPlus/http/fav.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:PiliPlus/http/video.dart';
|
||||||
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
||||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||||
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
||||||
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
||||||
|
import 'package:PiliPlus/models_new/video/video_detail/data.dart';
|
||||||
|
import 'package:PiliPlus/models_new/video/video_detail/page.dart' show Part;
|
||||||
import 'package:PiliPlus/pages/common/multi_select/base.dart';
|
import 'package:PiliPlus/pages/common/multi_select/base.dart';
|
||||||
import 'package:PiliPlus/pages/common/search/common_search_controller.dart';
|
import 'package:PiliPlus/pages/common/search/common_search_controller.dart';
|
||||||
import 'package:PiliPlus/pages/fav_detail/controller.dart';
|
import 'package:PiliPlus/pages/fav_detail/controller.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class FavSearchController
|
class FavSearchController
|
||||||
@@ -57,20 +61,31 @@ class FavSearchController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// TODO: dimension
|
Future<void> onViewFav(FavDetailItemModel item, int? index) async {
|
||||||
void onViewFav(FavDetailItemModel item, int? index) => PageUtils.toVideoPage(
|
final cid = item.ugc!.firstCid!;
|
||||||
bvid: item.bvid,
|
Part? part;
|
||||||
cid: item.ugc!.firstCid!,
|
VideoDetailData? videoIntro;
|
||||||
cover: item.cover,
|
final res = await VideoHttp.videoIntro(bvid: item.bvid!);
|
||||||
title: item.title,
|
if (res case Success(:final response)) {
|
||||||
extraArguments: {
|
videoIntro = response;
|
||||||
'sourceType': SourceType.fav,
|
part = response.pages?.firstWhereOrNull((e) => e.cid == cid);
|
||||||
'mediaId': mediaId,
|
}
|
||||||
'oid': item.id,
|
PageUtils.toVideoPage(
|
||||||
'favTitle': title,
|
bvid: item.bvid,
|
||||||
'count': count,
|
cid: item.ugc!.firstCid!,
|
||||||
'desc': true,
|
cover: item.cover,
|
||||||
'isContinuePlaying': true,
|
title: item.title,
|
||||||
},
|
dimension: part?.dimension,
|
||||||
);
|
extraArguments: {
|
||||||
|
'videoIntro': videoIntro,
|
||||||
|
'sourceType': SourceType.fav,
|
||||||
|
'mediaId': mediaId,
|
||||||
|
'oid': item.id,
|
||||||
|
'favTitle': title,
|
||||||
|
'count': count,
|
||||||
|
'desc': true,
|
||||||
|
'isContinuePlaying': true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import 'package:PiliPlus/models/common/video/source_type.dart';
|
|||||||
import 'package:PiliPlus/models_new/member_card_info/data.dart';
|
import 'package:PiliPlus/models_new/member_card_info/data.dart';
|
||||||
import 'package:PiliPlus/models_new/relation/data.dart';
|
import 'package:PiliPlus/models_new/relation/data.dart';
|
||||||
import 'package:PiliPlus/models_new/video/video_ai_conclusion/model_result.dart';
|
import 'package:PiliPlus/models_new/video/video_ai_conclusion/model_result.dart';
|
||||||
|
import 'package:PiliPlus/models_new/video/video_detail/data.dart';
|
||||||
import 'package:PiliPlus/models_new/video/video_detail/dimension.dart';
|
import 'package:PiliPlus/models_new/video/video_detail/dimension.dart';
|
||||||
import 'package:PiliPlus/models_new/video/video_detail/episode.dart';
|
import 'package:PiliPlus/models_new/video/video_detail/episode.dart';
|
||||||
import 'package:PiliPlus/models_new/video/video_detail/page.dart';
|
import 'package:PiliPlus/models_new/video/video_detail/page.dart';
|
||||||
@@ -70,54 +71,28 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
|||||||
videoDetail.value.title = Get.arguments['title'] ?? '';
|
videoDetail.value.title = Get.arguments['title'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initQueryVideoIntro(Map args) {
|
||||||
|
if (args['videoIntro'] case final VideoDetailData videoIntro?) {
|
||||||
|
handleIntroRes(videoIntro);
|
||||||
|
queryVideoTags();
|
||||||
|
if (isLogin) {
|
||||||
|
queryAllStatus();
|
||||||
|
queryFollowStatus();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
queryVideoIntro();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取视频简介&分p
|
// 获取视频简介&分p
|
||||||
@override
|
@override
|
||||||
Future<void> queryVideoIntro() async {
|
Future<void> queryVideoIntro() async {
|
||||||
queryVideoTags();
|
queryVideoTags();
|
||||||
|
|
||||||
final res = await VideoHttp.videoIntro(bvid: bvid);
|
final res = await VideoHttp.videoIntro(bvid: bvid);
|
||||||
if (res case Success(:final response)) {
|
if (res case Success(:final response)) {
|
||||||
if (response.redirectUrl != null &&
|
handleIntroRes(response);
|
||||||
videoDetailCtr.epId == null &&
|
|
||||||
videoDetailCtr.seasonId == null) {
|
|
||||||
if (!isClosed) {
|
|
||||||
PageUtils.viewPgcFromUri(response.redirectUrl!, off: true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
videoPlayerServiceHandler?.onVideoDetailChange(
|
|
||||||
response,
|
|
||||||
cid.value,
|
|
||||||
heroTag,
|
|
||||||
);
|
|
||||||
if (videoDetail.value.ugcSeason?.id == response.ugcSeason?.id) {
|
|
||||||
// keep reversed season
|
|
||||||
response.ugcSeason = videoDetail.value.ugcSeason;
|
|
||||||
}
|
|
||||||
if (videoDetail.value.cid == response.cid) {
|
|
||||||
// keep reversed pages
|
|
||||||
response
|
|
||||||
..pages = videoDetail.value.pages
|
|
||||||
..isPageReversed = videoDetail.value.isPageReversed;
|
|
||||||
}
|
|
||||||
videoDetail.value = response;
|
|
||||||
try {
|
|
||||||
if (videoDetailCtr.cover.value.isEmpty ||
|
|
||||||
(videoDetailCtr.videoUrl.isNullOrEmpty &&
|
|
||||||
!videoDetailCtr.isQuerying)) {
|
|
||||||
videoDetailCtr.cover.value = response.pic ?? '';
|
|
||||||
}
|
|
||||||
if (videoDetailCtr.showReply) {
|
|
||||||
try {
|
|
||||||
Get.find<VideoReplyController>(tag: heroTag).count.value =
|
|
||||||
response.stat?.reply ?? 0;
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
|
||||||
final pages = videoDetail.value.pages;
|
|
||||||
if (pages != null && pages.isNotEmpty && cid.value == 0) {
|
|
||||||
cid.value = pages.first.cid!;
|
|
||||||
}
|
|
||||||
queryUserStat(response.staff);
|
|
||||||
} else {
|
} else {
|
||||||
res.toast();
|
res.toast();
|
||||||
status.value = false;
|
status.value = false;
|
||||||
@@ -129,6 +104,51 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleIntroRes(VideoDetailData response) {
|
||||||
|
if (response.redirectUrl != null &&
|
||||||
|
videoDetailCtr.epId == null &&
|
||||||
|
videoDetailCtr.seasonId == null) {
|
||||||
|
if (!isClosed) {
|
||||||
|
PageUtils.viewPgcFromUri(response.redirectUrl!, off: true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
videoPlayerServiceHandler?.onVideoDetailChange(
|
||||||
|
response,
|
||||||
|
cid.value,
|
||||||
|
heroTag,
|
||||||
|
);
|
||||||
|
if (videoDetail.value.ugcSeason?.id == response.ugcSeason?.id) {
|
||||||
|
// keep reversed season
|
||||||
|
response.ugcSeason = videoDetail.value.ugcSeason;
|
||||||
|
}
|
||||||
|
if (videoDetail.value.cid == response.cid) {
|
||||||
|
// keep reversed pages
|
||||||
|
response
|
||||||
|
..pages = videoDetail.value.pages
|
||||||
|
..isPageReversed = videoDetail.value.isPageReversed;
|
||||||
|
}
|
||||||
|
videoDetail.value = response;
|
||||||
|
try {
|
||||||
|
if (videoDetailCtr.cover.value.isEmpty ||
|
||||||
|
(videoDetailCtr.videoUrl.isNullOrEmpty &&
|
||||||
|
!videoDetailCtr.isQuerying)) {
|
||||||
|
videoDetailCtr.cover.value = response.pic ?? '';
|
||||||
|
}
|
||||||
|
if (videoDetailCtr.showReply) {
|
||||||
|
try {
|
||||||
|
Get.find<VideoReplyController>(tag: heroTag).count.value =
|
||||||
|
response.stat?.reply ?? 0;
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
final pages = videoDetail.value.pages;
|
||||||
|
if (pages != null && pages.isNotEmpty && cid.value == 0) {
|
||||||
|
cid.value = pages.first.cid!;
|
||||||
|
}
|
||||||
|
queryUserStat(response.staff);
|
||||||
|
}
|
||||||
|
|
||||||
// 获取up主粉丝数
|
// 获取up主粉丝数
|
||||||
Future<void> queryUserStat(List<Staff>? staff) async {
|
Future<void> queryUserStat(List<Staff>? staff) async {
|
||||||
if (staff != null && staff.isNotEmpty) {
|
if (staff != null && staff.isNotEmpty) {
|
||||||
|
|||||||
Reference in New Issue
Block a user