mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-26 22:42:17 +00:00
fix: reuse loaded streams when Next Episode tapped during autoplay countdown
When the autoplay job has already located a stream for the next episode and the countdown (3-2-1) is running, tapping the Next button cancels the countdown coroutine and relaunches the full stream search from scratch. This causes a visible 'Searching...' flicker and unnecessary re-fetching of streams that were already found. Fix: in playNextEpisode(), check episodeStreamsState for already-loaded streams before starting a new search. If streams are present, cancel the running job and immediately play the first one. Falls back to the full search path only when no streams are yet available.
This commit is contained in:
parent
acaec75b54
commit
87dfe99c21
1 changed files with 16 additions and 0 deletions
|
|
@ -371,6 +371,22 @@ internal fun PlayerScreenRuntime.switchToDownloadedEpisode(downloadItem: Downloa
|
|||
}
|
||||
|
||||
internal fun PlayerScreenRuntime.playNextEpisode() {
|
||||
// If streams for the next episode are already loaded (e.g. autoplay found one
|
||||
// during its countdown), re-use them immediately instead of restarting the
|
||||
// entire search. This prevents a visible "Searching…" flicker when the user
|
||||
// manually taps the Next Episode button while the countdown is in progress.
|
||||
val nextVideoId = nextEpisodeInfo?.videoId
|
||||
val nextVideo = nextVideoId?.let { id -> playerMetaVideos.firstOrNull { it.id == id } }
|
||||
if (nextVideo != null && nextEpisodeInfo?.hasAired == true) {
|
||||
val cachedStreams = PlayerStreamsRepository.episodeStreamsState.value.groups
|
||||
.flatMap { it.streams }
|
||||
if (cachedStreams.isNotEmpty()) {
|
||||
nextEpisodeAutoPlayJob?.cancel()
|
||||
switchToEpisodeStream(cachedStreams.first(), nextVideo)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
scope.launchPlayerNextEpisodeAutoPlay(
|
||||
previousJob = nextEpisodeAutoPlayJob,
|
||||
nextEpisodeInfo = nextEpisodeInfo,
|
||||
|
|
|
|||
Loading…
Reference in a new issue