mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-26 13:25:49 +08:00
Sync progress if needed before exit (#1896)
* fix: 定时关闭退出APP前同步视频进度 * update --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -17,7 +17,6 @@ import 'package:PiliPlus/models/user/danmaku_rule.dart';
|
||||
import 'package:PiliPlus/models/video/play/url.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_shot/data.dart';
|
||||
import 'package:PiliPlus/pages/danmaku/danmaku_model.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/pages/sponsor_block/block_mixin.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/data_source.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/data_status.dart';
|
||||
@@ -1525,7 +1524,7 @@ class PlPlayerController with BlockConfigMixin {
|
||||
// 记录播放记录
|
||||
Future<void>? makeHeartBeat(
|
||||
int progress, {
|
||||
HeartBeatType type = HeartBeatType.playing,
|
||||
HeartBeatType type = .playing,
|
||||
bool isManual = false,
|
||||
dynamic aid,
|
||||
dynamic bvid,
|
||||
@@ -1535,22 +1534,12 @@ class PlPlayerController with BlockConfigMixin {
|
||||
dynamic pgcType,
|
||||
VideoType? videoType,
|
||||
}) {
|
||||
if (isLive) {
|
||||
if (isLive ||
|
||||
!enableHeart ||
|
||||
progress == 0 ||
|
||||
(playerStatus.isPaused && !isManual)) {
|
||||
return null;
|
||||
}
|
||||
if (!enableHeart || MineController.anonymity.value || progress == 0) {
|
||||
return null;
|
||||
} else if (playerStatus.isPaused) {
|
||||
if (!isManual) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
bool isComplete =
|
||||
playerStatus.isCompleted || type == HeartBeatType.completed;
|
||||
if ((duration.value - position).inMilliseconds > 1000) {
|
||||
isComplete = false;
|
||||
}
|
||||
// 播放状态变化时,更新
|
||||
|
||||
Future<void> send() {
|
||||
return VideoHttp.heartBeat(
|
||||
@@ -1566,18 +1555,21 @@ class PlPlayerController with BlockConfigMixin {
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case HeartBeatType.playing:
|
||||
case .playing:
|
||||
if (progress - _heartDuration >= 5) {
|
||||
_heartDuration = progress;
|
||||
return send();
|
||||
}
|
||||
case HeartBeatType.status:
|
||||
case .status:
|
||||
if (progress - _heartDuration >= 2) {
|
||||
_heartDuration = progress;
|
||||
return send();
|
||||
}
|
||||
case HeartBeatType.completed:
|
||||
if (isComplete) progress = -1;
|
||||
case .completed:
|
||||
if (playerStatus.isCompleted &&
|
||||
(duration.value - position).inMilliseconds <= 1000) {
|
||||
progress = -1;
|
||||
}
|
||||
return send();
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user