Fix:Close open playback session on server when local playback session syncing from mobile

This commit is contained in:
advplyr 2023-01-15 15:00:18 -06:00
parent 702ee3d350
commit 6dec750d3e
3 changed files with 21 additions and 8 deletions

View File

@ -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) {

View File

@ -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)

View File

@ -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') {