mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
opt: heartbeat
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -286,6 +286,16 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
void _makeHeartBeat() {
|
||||||
|
plPlayerController!.makeHeartBeat(
|
||||||
|
plPlayerController!.positionSeconds.value,
|
||||||
|
type: 'status',
|
||||||
|
isManual: true,
|
||||||
|
bvid: videoDetailController.bvid,
|
||||||
|
cid: videoDetailController.cid.value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
@@ -306,6 +316,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
shutdownTimerService.handleWaitingFinished();
|
shutdownTimerService.handleWaitingFinished();
|
||||||
// _bufferedListener?.cancel();
|
// _bufferedListener?.cancel();
|
||||||
if (plPlayerController != null) {
|
if (plPlayerController != null) {
|
||||||
|
_makeHeartBeat();
|
||||||
plPlayerController!.removeStatusLister(playerListener);
|
plPlayerController!.removeStatusLister(playerListener);
|
||||||
plPlayerController!.dispose();
|
plPlayerController!.dispose();
|
||||||
} else {
|
} else {
|
||||||
@@ -338,6 +349,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
videoDetailController.brightness = plPlayerController?.brightness.value;
|
videoDetailController.brightness = plPlayerController?.brightness.value;
|
||||||
}
|
}
|
||||||
if (plPlayerController != null) {
|
if (plPlayerController != null) {
|
||||||
|
_makeHeartBeat();
|
||||||
videoDetailController.defaultST = plPlayerController!.position.value;
|
videoDetailController.defaultST = plPlayerController!.position.value;
|
||||||
plPlayerController!.removeStatusLister(playerListener);
|
plPlayerController!.removeStatusLister(playerListener);
|
||||||
plPlayerController!.pause();
|
plPlayerController!.pause();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'dart:io';
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:PiliPalaX/common/widgets/segment_progress_bar.dart';
|
import 'package:PiliPalaX/common/widgets/segment_progress_bar.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -1243,12 +1244,19 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 记录播放记录
|
// 记录播放记录
|
||||||
Future makeHeartBeat(int progress, {type = 'playing'}) async {
|
Future makeHeartBeat(
|
||||||
if (!_enableHeart ||
|
int progress, {
|
||||||
MineController.anonymity ||
|
type = 'playing',
|
||||||
progress == 0 ||
|
bool isManual = false,
|
||||||
playerStatus.status.value == PlayerStatus.paused) {
|
dynamic bvid,
|
||||||
return false;
|
dynamic cid,
|
||||||
|
}) async {
|
||||||
|
if (!_enableHeart || MineController.anonymity || progress == 0) {
|
||||||
|
return;
|
||||||
|
} else if (playerStatus.status.value == PlayerStatus.paused) {
|
||||||
|
if (isManual.not) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (videoType.value == 'live') {
|
if (videoType.value == 'live') {
|
||||||
return;
|
return;
|
||||||
@@ -1259,8 +1267,8 @@ class PlPlayerController {
|
|||||||
|
|
||||||
if (type == 'status' || type == 'completed') {
|
if (type == 'status' || type == 'completed') {
|
||||||
await VideoHttp.heartBeat(
|
await VideoHttp.heartBeat(
|
||||||
bvid: _bvid,
|
bvid: bvid ?? _bvid,
|
||||||
cid: _cid,
|
cid: cid ?? _cid,
|
||||||
progress: isComplete ? -1 : progress,
|
progress: isComplete ? -1 : progress,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -1269,8 +1277,8 @@ class PlPlayerController {
|
|||||||
else if (progress - _heartDuration >= 5) {
|
else if (progress - _heartDuration >= 5) {
|
||||||
_heartDuration = progress;
|
_heartDuration = progress;
|
||||||
await VideoHttp.heartBeat(
|
await VideoHttp.heartBeat(
|
||||||
bvid: _bvid,
|
bvid: bvid ?? _bvid,
|
||||||
cid: _cid,
|
cid: cid ?? _cid,
|
||||||
progress: progress,
|
progress: progress,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user