mod: playCount calc

This commit is contained in:
guozhigq
2024-04-27 15:32:05 +08:00
parent 1f1d4fe5e9
commit d8699c2985
4 changed files with 19 additions and 17 deletions

View File

@ -26,7 +26,7 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
static final List<MediaItem> _item = [];
Box setting = GStrorage.setting;
bool enableBackgroundPlay = false;
PlPlayerController player = PlPlayerController.getInstance();
PlPlayerController player = PlPlayerController.getInstance(videoType: 'none');
VideoPlayerServiceHandler() {
revalidateSetting();

View File

@ -18,7 +18,7 @@ class AudioSessionHandler {
session.configure(const AudioSessionConfiguration.music());
session.interruptionEventStream.listen((event) {
final player = PlPlayerController.getInstance();
final player = PlPlayerController.getInstance(videoType: 'none');
if (event.begin) {
if (!player.playerStatus.playing) return;
switch (event.type) {
@ -51,7 +51,7 @@ class AudioSessionHandler {
// 耳机拔出暂停
session.becomingNoisyEventStream.listen((_) {
final player = PlPlayerController.getInstance();
final player = PlPlayerController.getInstance(videoType: 'none');
if (player.playerStatus.playing) {
player.pause();
}

View File

@ -29,8 +29,8 @@ class ShutdownTimerService {
return;
}
SmartDialog.showToast("设置 $scheduledExitInMinutes 分钟后定时关闭");
_shutdownTimer = Timer(Duration(minutes: scheduledExitInMinutes),
() => _shutdownDecider());
_shutdownTimer = Timer(
Duration(minutes: scheduledExitInMinutes), () => _shutdownDecider());
}
void _showTimeUpButPauseDialog() {
@ -59,7 +59,7 @@ class ShutdownTimerService {
// Start the 10-second timer to auto close the dialog
_autoCloseDialogTimer?.cancel();
_autoCloseDialogTimer = Timer(const Duration(seconds: 10), () {
SmartDialog.dismiss();// Close the dialog
SmartDialog.dismiss(); // Close the dialog
_executeShutdown();
});
return AlertDialog(
@ -88,7 +88,8 @@ class ShutdownTimerService {
_showShutdownDialog();
return;
}
PlPlayerController plPlayerController = PlPlayerController.getInstance();
PlPlayerController plPlayerController =
PlPlayerController.getInstance(videoType: 'none');
if (!exitApp && !waitForPlayingCompleted) {
if (!plPlayerController.playerStatus.playing) {
//仅提示用户
@ -108,19 +109,22 @@ class ShutdownTimerService {
//该方法依赖耦合实现,不够优雅
isWaiting = true;
}
void handleWaitingFinished(){
if(isWaiting){
void handleWaitingFinished() {
if (isWaiting) {
_showShutdownDialog();
isWaiting = false;
}
}
void _executeShutdown() {
if (exitApp) {
//退出app
exit(0);
} else {
//暂停播放
PlPlayerController plPlayerController = PlPlayerController.getInstance();
PlPlayerController plPlayerController =
PlPlayerController.getInstance(videoType: 'none');
if (plPlayerController.playerStatus.playing) {
plPlayerController.pause();
waitForPlayingCompleted = true;