Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Going from a video to audio in a playlist fails with Uncaught (in promise) Error: player cannot be null #5486

Open
kevgrig opened this issue May 13, 2024 · 1 comment · May be fixed by #5488
Labels
bug Something isn't working

Comments

@kevgrig
Copy link

kevgrig commented May 13, 2024

Describe The Bug
A mixed playlist with video and audio fails to advance to an audio file after a video file finishes.

Steps To Reproduce

  1. Create playlist with mp4 followed by an mp3
  2. Play mp4 and expect for it to move to the mp3
  3. Instead, playback ends and the console shows an error:
 Uncaught (in promise) Error: player cannot be null
    currentMediaSource playbackmanager.js:713
    getPreviousSource playbackmanager.js:2993
    nextTrack playbackmanager.js:3020
    onPlaybackStopped playbackmanager.js:3379
    promise callback*onPlaybackStopped playbackmanager.js:3377
    trigger events.ts:55
    trigger events.ts:54
    onEndedInternal htmlMediaHelper.js:339
    HtmlVideoPlayer plugin.js:889 [...]

I added some debug to playbackmanager.js } setCurrentPlayerInternal and I can see that the player is set to null right before nextTrack is called which explains why the exception is thrown:

setCurrentPlayerInternal called
current player: Object { name: "Html Video Player", type: "mediaplayer", id: "htmlvideoplayer" [...]
new player: null
playing next track
Uncaught (in promise) Error: player cannot be null

So I think the question is why is setCurrentPlayerInternal called with null or why isn't it called with an audio player?

Expected Behavior
Mixed playlist works

System (please complete the following information):

  • Platform: Linux
  • Browser: Firefox
  • Jellyfin Version: 10.9.1
@kevgrig kevgrig added the bug Something isn't working label May 13, 2024
@kevgrig
Copy link
Author

kevgrig commented May 13, 2024

The problem is here:

            const newPlayer = nextItem ? getPlayer(nextItem.item, nextItemPlayOptions) : null;

            if (newPlayer !== player) {
                data.streamInfo = null;
                destroyPlayer(player);
                removeCurrentPlayer(player);
            }

            if (errorOccurred) {
                showPlaybackInfoErrorMessage(self, 'PlaybackError' + displayErrorCode);
            } else if (nextItem) {
                const apiClient = ServerConnections.getApiClient(nextItem.item.ServerId);

                apiClient.getCurrentUser().then(function (user) {
                    if (user.Configuration.EnableNextEpisodeAutoPlay || nextMediaType !== MediaType.Video) {
                        self.nextTrack();

The newPlayer is the Html Audio Player which is !== to the Html Video Player so removeCurrentPlayer is called that nulls out the currently set player. However, later down, when self.nextTrack(); is called, it will then use this null player.

It works to just pass newPlayer to nextTrack:

diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js
index 14b23ad94..99b70b902 100644
--- a/src/components/playback/playbackmanager.js
+++ b/src/components/playback/playbackmanager.js
@@ -3371,7 +3371,7 @@ class PlaybackManager {
 
                 apiClient.getCurrentUser().then(function (user) {
                     if (user.Configuration.EnableNextEpisodeAutoPlay || nextMediaType !== MediaType.Video) {
-                        self.nextTrack();
+                        self.nextTrack(newPlayer);
                     }
                 });
             }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant