mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Fix:Persist playback rate #419
This commit is contained in:
parent
b2d299dba6
commit
3dbce8fd71
@ -69,7 +69,8 @@ export default {
|
|||||||
sleepTimerTime: 0,
|
sleepTimerTime: 0,
|
||||||
sleepTimerRemaining: 0,
|
sleepTimerRemaining: 0,
|
||||||
sleepTimer: null,
|
sleepTimer: null,
|
||||||
displayTitle: null
|
displayTitle: null,
|
||||||
|
initialPlaybackRate: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -204,6 +205,7 @@ export default {
|
|||||||
this.playerHandler.setVolume(volume)
|
this.playerHandler.setVolume(volume)
|
||||||
},
|
},
|
||||||
setPlaybackRate(playbackRate) {
|
setPlaybackRate(playbackRate) {
|
||||||
|
this.initialPlaybackRate = playbackRate
|
||||||
this.playerHandler.setPlaybackRate(playbackRate)
|
this.playerHandler.setPlaybackRate(playbackRate)
|
||||||
},
|
},
|
||||||
seek(time) {
|
seek(time) {
|
||||||
@ -253,7 +255,7 @@ export default {
|
|||||||
libraryItem: session.libraryItem,
|
libraryItem: session.libraryItem,
|
||||||
episodeId: session.episodeId
|
episodeId: session.episodeId
|
||||||
})
|
})
|
||||||
this.playerHandler.prepareOpenSession(session)
|
this.playerHandler.prepareOpenSession(session, this.initialPlaybackRate)
|
||||||
},
|
},
|
||||||
streamOpen(session) {
|
streamOpen(session) {
|
||||||
console.log(`[StreamContainer] Stream session open`, session)
|
console.log(`[StreamContainer] Stream session open`, session)
|
||||||
@ -311,7 +313,7 @@ export default {
|
|||||||
episodeId
|
episodeId
|
||||||
})
|
})
|
||||||
|
|
||||||
this.playerHandler.load(libraryItem, episodeId, true)
|
this.playerHandler.load(libraryItem, episodeId, true, this.initialPlaybackRate)
|
||||||
},
|
},
|
||||||
pauseItem() {
|
pauseItem() {
|
||||||
this.playerHandler.pause()
|
this.playerHandler.pause()
|
||||||
|
@ -10,6 +10,7 @@ export default class PlayerHandler {
|
|||||||
this.displayTitle = null
|
this.displayTitle = null
|
||||||
this.displayAuthor = null
|
this.displayAuthor = null
|
||||||
this.playWhenReady = false
|
this.playWhenReady = false
|
||||||
|
this.initialPlaybackRate = 1
|
||||||
this.player = null
|
this.player = null
|
||||||
this.playerState = 'IDLE'
|
this.playerState = 'IDLE'
|
||||||
this.isHlsTranscode = false
|
this.isHlsTranscode = false
|
||||||
@ -46,12 +47,13 @@ export default class PlayerHandler {
|
|||||||
return this.libraryItem.media.episodes.find(ep => ep.id === this.episodeId)
|
return this.libraryItem.media.episodes.find(ep => ep.id === this.episodeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
load(libraryItem, episodeId, playWhenReady) {
|
load(libraryItem, episodeId, playWhenReady, playbackRate) {
|
||||||
if (!this.player) this.switchPlayer()
|
if (!this.player) this.switchPlayer()
|
||||||
|
|
||||||
this.libraryItem = libraryItem
|
this.libraryItem = libraryItem
|
||||||
this.episodeId = episodeId
|
this.episodeId = episodeId
|
||||||
this.playWhenReady = playWhenReady
|
this.playWhenReady = playWhenReady
|
||||||
|
this.initialPlaybackRate = playbackRate
|
||||||
this.prepare()
|
this.prepare()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +115,7 @@ export default class PlayerHandler {
|
|||||||
console.log('[PlayerHandler] Player state change', state)
|
console.log('[PlayerHandler] Player state change', state)
|
||||||
this.playerState = state
|
this.playerState = state
|
||||||
if (this.playerState === 'PLAYING') {
|
if (this.playerState === 'PLAYING') {
|
||||||
|
this.setPlaybackRate(this.initialPlaybackRate)
|
||||||
this.startPlayInterval()
|
this.startPlayInterval()
|
||||||
} else {
|
} else {
|
||||||
this.stopPlayInterval()
|
this.stopPlayInterval()
|
||||||
@ -151,11 +154,12 @@ export default class PlayerHandler {
|
|||||||
this.prepareSession(session)
|
this.prepareSession(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareOpenSession(session) { // Session opened on init socket
|
prepareOpenSession(session, playbackRate) { // Session opened on init socket
|
||||||
if (!this.player) this.switchPlayer()
|
if (!this.player) this.switchPlayer()
|
||||||
|
|
||||||
this.libraryItem = session.libraryItem
|
this.libraryItem = session.libraryItem
|
||||||
this.playWhenReady = false
|
this.playWhenReady = false
|
||||||
|
this.initialPlaybackRate = playbackRate
|
||||||
this.prepareSession(session)
|
this.prepareSession(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +296,7 @@ export default class PlayerHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setPlaybackRate(playbackRate) {
|
setPlaybackRate(playbackRate) {
|
||||||
|
this.initialPlaybackRate = playbackRate // Might be loaded from settings before player is started
|
||||||
if (!this.player) return
|
if (!this.player) return
|
||||||
this.player.setPlaybackRate(playbackRate)
|
this.player.setPlaybackRate(playbackRate)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user