fix: auto-skip credits honors auto-play-next

close #901
This commit is contained in:
edde746
2026-04-21 17:37:31 +02:00
parent 775998466d
commit 7c331e51e6
2 changed files with 13 additions and 7 deletions
+1
View File
@@ -3440,6 +3440,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
}
},
onBack: _handleBackButton,
onReachedEnd: () => _onVideoCompleted(true),
canControl: canControl,
hasFirstFrame: _hasFirstFrame,
playNextFocusNode: _showPlayNextDialog ? _playNextConfirmFocusNode : null,
+12 -7
View File
@@ -79,6 +79,7 @@ Widget plexVideoControlsBuilder(
Function(SubtitleTrack)? onSecondarySubtitleTrackChanged,
Function(Duration position)? onSeekCompleted,
VoidCallback? onBack,
VoidCallback? onReachedEnd,
bool canControl = true,
ValueNotifier<bool>? hasFirstFrame,
FocusNode? playNextFocusNode,
@@ -116,6 +117,7 @@ Widget plexVideoControlsBuilder(
onSecondarySubtitleTrackChanged: onSecondarySubtitleTrackChanged,
onSeekCompleted: onSeekCompleted,
onBack: onBack,
onReachedEnd: onReachedEnd,
canControl: canControl,
hasFirstFrame: hasFirstFrame,
playNextFocusNode: playNextFocusNode,
@@ -158,6 +160,11 @@ class PlexVideoControls extends StatefulWidget {
/// Called when back button is pressed (for Watch Together session leave confirmation)
final VoidCallback? onBack;
/// Called when the video has effectively reached the end (e.g. credits extend
/// to EOF and can't be seeked past). Parent should route this into its
/// normal completion flow so the auto-play-next setting is honored.
final VoidCallback? onReachedEnd;
/// Whether the user can control playback (false in host-only mode for non-host).
final bool canControl;
@@ -231,6 +238,7 @@ class PlexVideoControls extends StatefulWidget {
this.onSecondarySubtitleTrackChanged,
this.onSeekCompleted,
this.onBack,
this.onReachedEnd,
this.canControl = true,
this.hasFirstFrame,
this.playNextFocusNode,
@@ -524,13 +532,10 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
final isAtEnd = duration > Duration.zero && (duration - endTime).inMilliseconds <= 1000;
if (marker.isCredits && isAtEnd) {
// Credits extend to end of video — don't seek (unreliable due to
// position stream throttling). Go to next episode or exit player.
if (widget.onNext != null) {
widget.onNext!.call();
} else {
widget.onBack?.call();
}
// Seeking to EOF is unreliable due to position stream throttling,
// so pause and defer to the parent's completion flow.
await widget.player.pause();
widget.onReachedEnd?.call();
} else {
await _seekToPosition(endTime);
}