mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
feat: video seek preview
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -5,8 +5,10 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/segment_progress_bar.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/models/common/audio_normalization.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:canvas_danmaku/canvas_danmaku.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
@@ -509,6 +511,12 @@ class PlPlayerController {
|
||||
_subType = subType;
|
||||
_enableHeart = enableHeart;
|
||||
|
||||
if (showSeekPreview) {
|
||||
videoShot = null;
|
||||
showPreview.value = false;
|
||||
localPosition.value = Offset.zero;
|
||||
}
|
||||
|
||||
if (_videoPlayerController != null &&
|
||||
_videoPlayerController!.state.playing) {
|
||||
await pause(notify: false);
|
||||
@@ -1564,4 +1572,33 @@ class PlPlayerController {
|
||||
videoPlayerController?.setVideoTrack(
|
||||
_onlyPlayAudio.value ? VideoTrack.no() : VideoTrack.auto());
|
||||
}
|
||||
|
||||
late final showSeekPreview = GStorage.showSeekPreview;
|
||||
late bool _isQueryingVideoShot = false;
|
||||
Map? videoShot;
|
||||
late final RxBool showPreview = false.obs;
|
||||
late final Rx<Offset> localPosition = Offset.zero.obs;
|
||||
|
||||
void getVideoShot() async {
|
||||
if (_isQueryingVideoShot) {
|
||||
return;
|
||||
}
|
||||
_isQueryingVideoShot = true;
|
||||
dynamic res = await Request().get(
|
||||
'https://api.bilibili.com/x/player/videoshot',
|
||||
queryParameters: {
|
||||
'aid': IdUtils.bv2av(_bvid),
|
||||
'cid': _cid,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
videoShot = {
|
||||
'status': true,
|
||||
'data': res.data['data'],
|
||||
};
|
||||
} else {
|
||||
videoShot = {'status': false};
|
||||
}
|
||||
_isQueryingVideoShot = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user