diff --git a/client/components/app/StreamContainer.vue b/client/components/app/StreamContainer.vue index 23cfb41f..95e29554 100644 --- a/client/components/app/StreamContainer.vue +++ b/client/components/app/StreamContainer.vue @@ -361,13 +361,15 @@ export default { } }, streamProgress(data) { - if (!data.numSegments) return - var chunks = data.chunks - console.log(`[StreamContainer] Stream Progress ${data.percent}`) - if (this.$refs.audioPlayer) { - this.$refs.audioPlayer.setChunksReady(chunks, data.numSegments) - } else { - console.error('No Audio Ref') + if (this.playerHandler.isPlayingLocalItem && this.playerHandler.currentStreamId === data.stream) { + if (!data.numSegments) return + var chunks = data.chunks + console.log(`[StreamContainer] Stream Progress ${data.percent}`) + if (this.$refs.audioPlayer) { + this.$refs.audioPlayer.setChunksReady(chunks, data.numSegments) + } else { + console.error('No Audio Ref') + } } }, sessionOpen(session) { diff --git a/server/managers/PlaybackSessionManager.js b/server/managers/PlaybackSessionManager.js index 9bcda576..6db65079 100644 --- a/server/managers/PlaybackSessionManager.js +++ b/server/managers/PlaybackSessionManager.js @@ -73,6 +73,17 @@ class PlaybackSessionManager { return res.status(500).send('Library item not found') } + // If server session is open for this same media item then close it + const userSessionForThisItem = this.sessions.find(playbackSession => { + if (playbackSession.userId !== user.id) return false + if (sessionJson.episodeId) return playbackSession.episodeId !== sessionJson.episodeId + return playbackSession.libraryItemId === sessionJson.libraryItemId + }) + if (userSessionForThisItem) { + Logger.info(`[PlaybackSessionManager] syncLocalSessionRequest: Closing open session "${userSessionForThisItem.displayTitle}" for user "${user.username}"`) + await this.closeSession(user, userSessionForThisItem, null) + } + this.localSessionLock[sessionJson.id] = true // Lock local session let session = await this.db.getPlaybackSession(sessionJson.id) diff --git a/server/objects/user/MediaProgress.js b/server/objects/user/MediaProgress.js index 3c4b4ca3..0abe7e22 100644 --- a/server/objects/user/MediaProgress.js +++ b/server/objects/user/MediaProgress.js @@ -72,7 +72,7 @@ class MediaProgress { } update(payload) { - var hasUpdates = false + let hasUpdates = false for (const key in payload) { if (this[key] !== undefined && payload[key] !== this[key]) { if (key === 'isFinished') {