mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 16:48:16 +08:00
opt: query sponsorblock
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1113,6 +1113,18 @@ class VideoDetailController extends GetxController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isQuerying = true;
|
isQuerying = true;
|
||||||
|
await Future.wait([
|
||||||
|
if (enableSponsorBlock) _querySponsorBlock(),
|
||||||
|
_actualQuery(),
|
||||||
|
]);
|
||||||
|
if (autoPlay.value && videoUrl != null && audioUrl != null) {
|
||||||
|
isShowCover.value = false;
|
||||||
|
await playerInit();
|
||||||
|
}
|
||||||
|
isQuerying = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _actualQuery() async {
|
||||||
if (cacheVideoQa == null) {
|
if (cacheVideoQa == null) {
|
||||||
await Connectivity().checkConnectivity().then((res) {
|
await Connectivity().checkConnectivity().then((res) {
|
||||||
cacheVideoQa = res.contains(ConnectivityResult.wifi)
|
cacheVideoQa = res.contains(ConnectivityResult.wifi)
|
||||||
@@ -1128,7 +1140,7 @@ class VideoDetailController extends GetxController
|
|||||||
defaultValue: AudioQuality.k192.code);
|
defaultValue: AudioQuality.k192.code);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var result = await VideoHttp.videoUrl(
|
dynamic result = await VideoHttp.videoUrl(
|
||||||
cid: cid.value,
|
cid: cid.value,
|
||||||
bvid: bvid,
|
bvid: bvid,
|
||||||
epid: epId,
|
epid: epId,
|
||||||
@@ -1137,15 +1149,14 @@ class VideoDetailController extends GetxController
|
|||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
data = result['data'];
|
data = result['data'];
|
||||||
|
|
||||||
if (enableSponsorBlock) {
|
|
||||||
await _querySponsorBlock();
|
|
||||||
}
|
|
||||||
if (data.acceptDesc!.isNotEmpty && data.acceptDesc!.contains('试看')) {
|
if (data.acceptDesc!.isNotEmpty && data.acceptDesc!.contains('试看')) {
|
||||||
SmartDialog.showToast(
|
SmartDialog.showToast(
|
||||||
'该视频为专属视频,仅提供试看',
|
'该视频为专属视频,仅提供试看',
|
||||||
displayTime: const Duration(seconds: 3),
|
displayTime: const Duration(seconds: 3),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// #1
|
||||||
if (data.dash == null && data.durl != null) {
|
if (data.dash == null && data.durl != null) {
|
||||||
videoUrl = data.durl!.first.url!;
|
videoUrl = data.durl!.first.url!;
|
||||||
audioUrl = '';
|
audioUrl = '';
|
||||||
@@ -1158,22 +1169,26 @@ class VideoDetailController extends GetxController
|
|||||||
quality: VideoQualityCode.fromCode(data.quality!)!);
|
quality: VideoQualityCode.fromCode(data.quality!)!);
|
||||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString('avc1')!;
|
currentDecodeFormats = VideoDecodeFormatsCode.fromString('avc1')!;
|
||||||
currentVideoQa = VideoQualityCode.fromCode(data.quality!)!;
|
currentVideoQa = VideoQualityCode.fromCode(data.quality!)!;
|
||||||
if (autoPlay.value) {
|
|
||||||
isShowCover.value = false;
|
/// await sponsorblock
|
||||||
await playerInit();
|
// if (autoPlay.value) {
|
||||||
}
|
// isShowCover.value = false;
|
||||||
|
// await playerInit();
|
||||||
|
// }
|
||||||
videoState.value = LoadingState.success(null);
|
videoState.value = LoadingState.success(null);
|
||||||
isQuerying = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// #2
|
||||||
if (data.dash == null) {
|
if (data.dash == null) {
|
||||||
SmartDialog.showToast('视频资源不存在');
|
SmartDialog.showToast('视频资源不存在');
|
||||||
autoPlay.value = false;
|
autoPlay.value = false;
|
||||||
isShowCover.value = true;
|
isShowCover.value = true;
|
||||||
videoState.value = LoadingState.success(null);
|
videoState.value = LoadingState.error('视频资源不存在');
|
||||||
isQuerying = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// #3
|
||||||
final List<VideoItem> allVideosList = data.dash!.video!;
|
final List<VideoItem> allVideosList = data.dash!.video!;
|
||||||
// debugPrint("allVideosList:${allVideosList}");
|
// debugPrint("allVideosList:${allVideosList}");
|
||||||
// 当前可播放的最高质量视频
|
// 当前可播放的最高质量视频
|
||||||
@@ -1267,13 +1282,17 @@ class VideoDetailController extends GetxController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
defaultST = Duration(milliseconds: data.lastPlayTime!);
|
defaultST = Duration(milliseconds: data.lastPlayTime!);
|
||||||
if (autoPlay.value) {
|
|
||||||
isShowCover.value = false;
|
/// await sponsorblock
|
||||||
await playerInit();
|
// if (autoPlay.value) {
|
||||||
}
|
// isShowCover.value = false;
|
||||||
|
// await playerInit();
|
||||||
|
// }
|
||||||
|
videoState.value = LoadingState.success(null);
|
||||||
} else {
|
} else {
|
||||||
autoPlay.value = false;
|
autoPlay.value = false;
|
||||||
isShowCover.value = true;
|
isShowCover.value = true;
|
||||||
|
videoState.value = LoadingState.error(result['msg']);
|
||||||
if (result['code'] == -404) {
|
if (result['code'] == -404) {
|
||||||
SmartDialog.showToast('视频不存在或已被删除');
|
SmartDialog.showToast('视频不存在或已被删除');
|
||||||
}
|
}
|
||||||
@@ -1283,8 +1302,6 @@ class VideoDetailController extends GetxController
|
|||||||
SmartDialog.showToast("错误(${result['code']}):${result['msg']}");
|
SmartDialog.showToast("错误(${result['code']}):${result['msg']}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isQuerying = false;
|
|
||||||
videoState.value = LoadingState.success(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PostSegmentModel>? list;
|
List<PostSegmentModel>? list;
|
||||||
|
|||||||
@@ -281,14 +281,14 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
|
|
||||||
/// 未开启自动播放时触发播放
|
/// 未开启自动播放时触发播放
|
||||||
Future<void> handlePlay() async {
|
Future<void> handlePlay() async {
|
||||||
|
if (videoDetailController.isQuerying) {
|
||||||
|
debugPrint('handlePlay: querying');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (videoDetailController.videoUrl == null ||
|
if (videoDetailController.videoUrl == null ||
|
||||||
videoDetailController.audioUrl == null) {
|
videoDetailController.audioUrl == null) {
|
||||||
// SmartDialog.showToast('not initialized');
|
|
||||||
debugPrint('handlePlay: videoUrl/audioUrl not initialized');
|
debugPrint('handlePlay: videoUrl/audioUrl not initialized');
|
||||||
if (videoDetailController.isQuerying.not) {
|
|
||||||
videoDetailController.autoPlay.value = true;
|
|
||||||
videoDetailController.queryVideoUrl();
|
videoDetailController.queryVideoUrl();
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plPlayerController = videoDetailController.plPlayerController;
|
plPlayerController = videoDetailController.plPlayerController;
|
||||||
|
|||||||
@@ -500,11 +500,9 @@ class PlPlayerController {
|
|||||||
dataSource, _looping, enableHA, hwdec, width, height);
|
dataSource, _looping, enableHA, hwdec, width, height);
|
||||||
// 获取视频时长 00:00
|
// 获取视频时长 00:00
|
||||||
_duration.value = duration ?? _videoPlayerController!.state.duration;
|
_duration.value = duration ?? _videoPlayerController!.state.duration;
|
||||||
_position.value =
|
_position.value = _sliderPosition.value = seekTo ?? Duration.zero;
|
||||||
_sliderPosition.value = _buffered.value = seekTo ?? Duration.zero;
|
|
||||||
updateDurationSecond();
|
updateDurationSecond();
|
||||||
updatePositionSecond();
|
updatePositionSecond();
|
||||||
updateBufferedSecond();
|
|
||||||
updateSliderPositionSecond();
|
updateSliderPositionSecond();
|
||||||
// 数据加载完成
|
// 数据加载完成
|
||||||
dataStatus.status.value = DataStatus.loaded;
|
dataStatus.status.value = DataStatus.loaded;
|
||||||
@@ -855,7 +853,11 @@ class PlPlayerController {
|
|||||||
await _videoPlayerController?.stream.buffer.first;
|
await _videoPlayerController?.stream.buffer.first;
|
||||||
}
|
}
|
||||||
danmakuController?.clear();
|
danmakuController?.clear();
|
||||||
|
try {
|
||||||
await _videoPlayerController?.seek(position);
|
await _videoPlayerController?.seek(position);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('seek failed: $e');
|
||||||
|
}
|
||||||
// if (playerStatus.stopped) {
|
// if (playerStatus.stopped) {
|
||||||
// play();
|
// play();
|
||||||
// }
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user