From b2d299dba6b01fb799974285b4c963e62b89908c Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 23 Apr 2022 16:18:34 -0500 Subject: [PATCH] Remove open playback sessions for user when starting a new playback session --- server/managers/PlaybackSessionManager.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/managers/PlaybackSessionManager.js b/server/managers/PlaybackSessionManager.js index 45f010fa..02bcdcf7 100644 --- a/server/managers/PlaybackSessionManager.js +++ b/server/managers/PlaybackSessionManager.js @@ -78,6 +78,13 @@ class PlaybackSessionManager { } async startSession(user, libraryItem, episodeId, options) { + // Close any sessions already open for user + var userSessions = this.sessions.filter(playbackSession => playbackSession.userId === user.id) + for (const session of userSessions) { + Logger.info(`[PlaybackSessionManager] startSession: Closing open session "${session.displayTitle}" for user "${user.username}"`) + await this.closeSession(user, session, null) + } + var shouldDirectPlay = options.forceDirectPlay || (!options.forceTranscode && libraryItem.media.checkCanDirectPlay(options, episodeId)) var mediaPlayer = options.mediaPlayer || 'unknown'