mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-23 23:28:15 +02:00
Fix: Resume playback not working - Hive storage issues
- Fixed Hive Map type conversion with safe iteration - Improved save logic to not require duration loaded - Added debug logging for troubleshooting - Save position even if duration not available yet
This commit is contained in:
1 parent
bf5893e545
commit
451dd082b0
2 files changed
+37
-11
No files matched your search
@@ -263,22 +263,31 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> {
|
||||
/// Save resume position when exiting player
|
||||
void _saveResumePositionOnExit() {
|
||||
if (widget.streamType == StreamType.live) return;
|
||||
if (_duration.inSeconds <= 0) return;
|
||||
|
||||
final progress = _position.inSeconds / _duration.inSeconds;
|
||||
debugPrint('MediaKitPlayer: Saving position - pos: ${_position.inSeconds}s, dur: ${_duration.inSeconds}s, contentId: $_contentId');
|
||||
|
||||
// Don't save if almost finished (> 90%) or already marked as watched
|
||||
if (progress > 0.90 || _hasMarkedAsWatched) {
|
||||
// If already marked as watched, clear any saved position
|
||||
if (_hasMarkedAsWatched) {
|
||||
ref.read(mobileWatchHistoryProvider.notifier).clearResumePosition(_contentId);
|
||||
debugPrint('MediaKitPlayer: Already watched, clearing position');
|
||||
return;
|
||||
}
|
||||
|
||||
// Save position
|
||||
// Check if almost finished (> 90%)
|
||||
if (_duration.inSeconds > 0) {
|
||||
final progress = _position.inSeconds / _duration.inSeconds;
|
||||
if (progress > 0.90) {
|
||||
ref.read(mobileWatchHistoryProvider.notifier).clearResumePosition(_contentId);
|
||||
debugPrint('MediaKitPlayer: Almost finished (${(progress * 100).toStringAsFixed(1)}%), clearing position');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Save position (saveResumePosition handles the 30s minimum check)
|
||||
ref.read(mobileWatchHistoryProvider.notifier).saveResumePosition(
|
||||
_contentId,
|
||||
_position.inSeconds,
|
||||
);
|
||||
debugPrint('MediaKitPlayer: Saved resume position at ${_position.inSeconds}s');
|
||||
}
|
||||
|
||||
/// Attempt to reconnect a live stream that stopped
|
||||
|
||||
Reference in new issue
Block a user