mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-11 17:29:26 +02:00
Fix: Resume playback retry logic + better debug logging
- Added _seekToResume() method with retry logic (max 10 attempts) - Seek now waits until player is playing AND has duration loaded - Added debug logging for resume position checks - 500ms retry interval with 1.5s initial delay
This commit is contained in:
1 parent
451dd082b0
commit
049de97a0b
1 file changed
+19
-7
@@ -290,6 +290,23 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Seek to resume position with retry logic
|
||||
void _seekToResume(int positionSeconds, [int attempt = 0]) {
|
||||
if (!mounted || attempt >= 10) return;
|
||||
|
||||
Future.delayed(Duration(milliseconds: attempt == 0 ? 1500 : 500), () {
|
||||
if (!mounted) return;
|
||||
|
||||
if (_isPlaying && _duration.inSeconds > 0) {
|
||||
debugPrint('MediaKitPlayer: Seeking to resume position ${positionSeconds}s (attempt $attempt)');
|
||||
_player.seek(Duration(seconds: positionSeconds));
|
||||
} else {
|
||||
debugPrint('MediaKitPlayer: Player not ready, retrying resume seek (attempt $attempt)');
|
||||
_seekToResume(positionSeconds, attempt + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Attempt to reconnect a live stream that stopped
|
||||
void _attemptReconnect() {
|
||||
if (!mounted) return;
|
||||
@@ -441,14 +458,9 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> {
|
||||
// Resume from saved position (VOD/Series only)
|
||||
if (widget.streamType != StreamType.live) {
|
||||
final resumePos = ref.read(mobileWatchHistoryProvider).getResumePosition(_contentId);
|
||||
debugPrint('MediaKitPlayer: Resume check - contentId: $_contentId, resumePos: $resumePos');
|
||||
if (resumePos > 30) {
|
||||
// Wait for player to stabilize, then seek
|
||||
Future.delayed(const Duration(milliseconds: 1500), () {
|
||||
if (mounted && _isPlaying) {
|
||||
debugPrint('MediaKitPlayer: Resuming from ${resumePos}s');
|
||||
_player.seek(Duration(seconds: resumePos));
|
||||
}
|
||||
});
|
||||
_seekToResume(resumePos);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in new issue
Block a user