mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
fix: Incorrect playback reporting (#221)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
f259151336
commit
3b4b8a9101
5 changed files with 13 additions and 27 deletions
|
|
@ -110,9 +110,7 @@ class DirectPlaybackModel implements PlaybackModel {
|
|||
mediaSourceId: item.id,
|
||||
playSessionId: playbackInfo.playSessionId,
|
||||
positionTicks: position.toRuntimeTicks,
|
||||
failed: false,
|
||||
),
|
||||
totalDuration: totalDuration,
|
||||
);
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -111,9 +111,7 @@ class TranscodePlaybackModel implements PlaybackModel {
|
|||
mediaSourceId: item.id,
|
||||
playSessionId: playbackInfo.playSessionId,
|
||||
positionTicks: position.toRuntimeTicks,
|
||||
failed: false,
|
||||
),
|
||||
totalDuration: totalDuration,
|
||||
);
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import 'package:fladder/models/items/trick_play_model.dart';
|
|||
import 'package:fladder/providers/auth_provider.dart';
|
||||
import 'package:fladder/providers/image_provider.dart';
|
||||
import 'package:fladder/providers/user_provider.dart';
|
||||
import 'package:fladder/util/duration_extensions.dart';
|
||||
import 'package:fladder/util/jellyfin_extension.dart';
|
||||
|
||||
class ServerQueryResult {
|
||||
|
|
@ -492,25 +491,8 @@ class JellyService {
|
|||
|
||||
Future<Response> sessionsPlayingStoppedPost({
|
||||
required PlaybackStopInfo? body,
|
||||
Duration? totalDuration,
|
||||
}) async {
|
||||
final position = body?.positionTicks;
|
||||
final totalTime = totalDuration?.toRuntimeTicks;
|
||||
final maxTime = ref.read(userProvider.select((value) => value?.serverConfiguration?.maxResumePct ?? 90));
|
||||
|
||||
final response = await api.sessionsPlayingStoppedPost(
|
||||
body: body?.copyWith(
|
||||
failed: false,
|
||||
),
|
||||
);
|
||||
|
||||
//This is a temporary fix
|
||||
if (totalTime != null && position != null && position > (totalTime * (maxTime / 100))) {
|
||||
await usersUserIdPlayedItemsItemIdPost(itemId: body?.itemId, datePlayed: DateTime.now());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}) =>
|
||||
api.sessionsPlayingStoppedPost(body: body);
|
||||
|
||||
Future<Response> sessionsPlayingProgressPost({required PlaybackProgressInfo? body}) async =>
|
||||
api.sessionsPlayingProgressPost(body: body);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class VideoPlayerNotifier extends StateNotifier<MediaControlsWrapper> {
|
|||
final lastPosition = ref.read(mediaPlaybackProvider.select((value) => value.lastPosition));
|
||||
final diff = (position.inMilliseconds - lastPosition.inMilliseconds).abs();
|
||||
|
||||
if (diff > const Duration(seconds: 1, milliseconds: 500).inMilliseconds) {
|
||||
if (diff > const Duration(seconds: 10).inMilliseconds) {
|
||||
mediaState.update((value) => value.copyWith(
|
||||
position: event,
|
||||
playing: playbackState.playing,
|
||||
|
|
|
|||
|
|
@ -204,6 +204,8 @@ class MediaControlsWrapper extends BaseAudioHandler {
|
|||
processingState: AudioProcessingState.ready,
|
||||
));
|
||||
|
||||
ref.read(playBackModel)?.playbackStarted(currentPosition ?? Duration.zero, ref);
|
||||
|
||||
return super.play();
|
||||
}
|
||||
|
||||
|
|
@ -232,16 +234,22 @@ class MediaControlsWrapper extends BaseAudioHandler {
|
|||
@override
|
||||
Future<void> stop() async {
|
||||
WakelockPlus.disable();
|
||||
final position = _player?.lastState.position;
|
||||
final totalDuration = _player?.lastState.duration;
|
||||
super.stop();
|
||||
_player?.stop();
|
||||
|
||||
final position = _player?.lastState.position;
|
||||
final totalDuration = _player?.lastState.duration;
|
||||
|
||||
//Small delay so we don't post right after playback/progress update
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
ref.read(playBackModel)?.playbackStopped(position ?? Duration.zero, totalDuration, ref);
|
||||
ref.read(mediaPlaybackProvider.notifier).update((state) => state.copyWith(position: Duration.zero));
|
||||
|
||||
smtc?.setPlaybackStatus(PlaybackStatus.stopped);
|
||||
smtc?.clearMetadata();
|
||||
smtc?.disableSmtc();
|
||||
|
||||
playbackState.add(
|
||||
playbackState.value.copyWith(
|
||||
playing: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue