mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-03-28 00:21:47 +01:00
Fix:Close open playback session on server when local playback session syncing from mobile
This commit is contained in:
parent
702ee3d350
commit
6dec750d3e
@ -361,13 +361,15 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
streamProgress(data) {
|
streamProgress(data) {
|
||||||
if (!data.numSegments) return
|
if (this.playerHandler.isPlayingLocalItem && this.playerHandler.currentStreamId === data.stream) {
|
||||||
var chunks = data.chunks
|
if (!data.numSegments) return
|
||||||
console.log(`[StreamContainer] Stream Progress ${data.percent}`)
|
var chunks = data.chunks
|
||||||
if (this.$refs.audioPlayer) {
|
console.log(`[StreamContainer] Stream Progress ${data.percent}`)
|
||||||
this.$refs.audioPlayer.setChunksReady(chunks, data.numSegments)
|
if (this.$refs.audioPlayer) {
|
||||||
} else {
|
this.$refs.audioPlayer.setChunksReady(chunks, data.numSegments)
|
||||||
console.error('No Audio Ref')
|
} else {
|
||||||
|
console.error('No Audio Ref')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sessionOpen(session) {
|
sessionOpen(session) {
|
||||||
|
@ -73,6 +73,17 @@ class PlaybackSessionManager {
|
|||||||
return res.status(500).send('Library item not found')
|
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
|
this.localSessionLock[sessionJson.id] = true // Lock local session
|
||||||
|
|
||||||
let session = await this.db.getPlaybackSession(sessionJson.id)
|
let session = await this.db.getPlaybackSession(sessionJson.id)
|
||||||
|
@ -72,7 +72,7 @@ class MediaProgress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update(payload) {
|
update(payload) {
|
||||||
var hasUpdates = false
|
let hasUpdates = false
|
||||||
for (const key in payload) {
|
for (const key in payload) {
|
||||||
if (this[key] !== undefined && payload[key] !== this[key]) {
|
if (this[key] !== undefined && payload[key] !== this[key]) {
|
||||||
if (key === 'isFinished') {
|
if (key === 'isFinished') {
|
||||||
|
Loading…
Reference in New Issue
Block a user