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,