jellyfin-web icon indicating copy to clipboard operation
jellyfin-web copied to clipboard

Pass the new player to nextTrack to allow mixed playlist playback

Open kevgrig opened this issue 1 year ago • 13 comments

Changes When a playlist is stopped (e.g. track finishes), if the player for the next playlist item is different, then this new player needs to be used as otherwise the current player has been nulled out.

Issues Fixes #5486

Summary by CodeRabbit

  • Bug Fixes
    • Improved playback transition handling to ensure smoother switching between media items.
    • Enhanced event notifications when playback stops and a new item is queued.

kevgrig avatar May 13 '24 02:05 kevgrig

Cloudflare Pages deployment

Latest commit 8f03986
Status ✅ Deployed!
Preview URL https://af3d0705.jellyfin-web.pages.dev
Type 🔀 Preview

View build logs View bot logs

jellyfin-bot avatar May 13 '24 08:05 jellyfin-bot

It crashes here (the player has been killed on the stop event): https://github.com/jellyfin/jellyfin-web/blob/edc70fece4adb4b833ef2e16f40c8c33fad9f5e3/src/components/playback/playbackmanager.js#L2989-L2990

IMO, passing a new player breaks the logic - getting the previous source from the new player.

We probably need to change this check: https://github.com/jellyfin/jellyfin-web/blob/edc70fece4adb4b833ef2e16f40c8c33fad9f5e3/src/components/playback/playbackmanager.js#L3361 to !newPlayer.

This: https://github.com/jellyfin/jellyfin-web/blob/edc70fece4adb4b833ef2e16f40c8c33fad9f5e3/src/components/playback/playbackmanager.js#L3369 to newPlayer.

And kill the player after the event is triggered: https://github.com/jellyfin/jellyfin-web/blob/edc70fece4adb4b833ef2e16f40c8c33fad9f5e3/src/components/playback/playbackmanager.js#L3409-L3414

So the previous player will be alive until it is no longer needed (for the next item).

In fact, our playback code is a mess and requires a lot of refactoring. At first glance, we should also kill the player on error, but this is probably handled by onInterceptorRejection.

dmitrylyzo avatar May 13 '24 09:05 dmitrylyzo

Makes sense, thanks. I'll try it out when I have a chance.

kevgrig avatar May 15 '24 00:05 kevgrig

to !newPlayer.

Done in latest commit and confirmed things still work for me.

And kill the player after the event is triggered:

I didn't follow this because isn't this already executing in onPlaybackStopped?

kevgrig avatar Jun 25 '24 00:06 kevgrig

Done in latest commit and confirmed things still work for me.

https://github.com/jellyfin/jellyfin-web/blob/1df1262d0ea7620d58627204a17e7ada3a175641/src/components/playback/playbackmanager.js#L3384

-> else if (newPlayer) { because we may have a nextItem but no available player (newPlayer is null).

I didn't follow this because isn't this already executing in onPlaybackStopped?

After replacing newPlayer !== player with !newPlayer, the old player will be alive when we switch to another player. So after the stop event is triggered, we need to destroy the old player, but only when it has been changed. Perhaps we can do this after calling nextTrack similar to the original: if (newPlayer !== player). I haven't tested this case - just guessing.

dmitrylyzo avatar Jun 25 '24 12:06 dmitrylyzo