From 22f46826088f4eef96bf04bd1d0c7c368075fd49 Mon Sep 17 00:00:00 2001 From: Cobb Date: Sat, 20 Jun 2026 09:56:08 -0700 Subject: [PATCH] Fix autoplay-next: play the next video instead of silently queuing it (vc=74 item 5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At STATE_ENDED the finished video is still loaded (mediaItemCount==1), so enqueueLast appended the autoplay candidate at index 1 and the ENDED player never advanced to it — autoplay did nothing. Switch tryAutoplay to setPlayingFrom, which replaces + prepares + plays the next video. The old comment's 'queue is empty' assumption was the root error. --- .../sulkta/straw/feature/player/PlaybackService.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/strawApp/src/main/kotlin/com/sulkta/straw/feature/player/PlaybackService.kt b/strawApp/src/main/kotlin/com/sulkta/straw/feature/player/PlaybackService.kt index 27b194117..10e2c6876 100644 --- a/strawApp/src/main/kotlin/com/sulkta/straw/feature/player/PlaybackService.kt +++ b/strawApp/src/main/kotlin/com/sulkta/straw/feature/player/PlaybackService.kt @@ -276,15 +276,19 @@ class PlaybackService : MediaSessionService() { // HIGH-3 family — every uniffi.strawcore.* site that // takes a user-influenced URL needs this gate. if (!isAllowedYtUrl(candidateUrl)) return@runCatchingCancellable - // Resolve + enqueue + auto-play. Because the queue is - // currently empty (we just ended), enqueueLast routes - // through setPlayingFrom (auto-starts). val info = withContext(Dispatchers.IO) { uniffi.strawcore.streamInfo(candidateUrl) } val resolved = resolveStreamPlayback(info) withContext(Dispatchers.Main) { - controller.enqueueLast( + // setPlayingFrom, NOT enqueueLast — at STATE_ENDED the + // just-finished video is still loaded (mediaItemCount==1), + // so enqueueLast would only append at index 1 and the + // ENDED player would never advance to it (that was the + // "autoplay does nothing" bug — the prior comment wrongly + // assumed the queue was empty). setPlayingFrom replaces + + // prepare()s + plays, which is exactly "play the next one." + controller.setPlayingFrom( streamUrl = candidateUrl, title = info.title, uploader = info.uploader,