This commit is contained in:
Neeraj singh 2026-07-24 20:05:43 +05:30 committed by GitHub
commit 36f5a8438e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,