Fix autoplay-next: play the next video instead of silently queuing it (vc=74 item 5)
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.
This commit is contained in:
parent
dd2345b1c8
commit
22f4682608
1 changed files with 8 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue