mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-17 08:12:00 +02:00
commit
3f63c4d157
3 changed files with 24 additions and 13 deletions
|
@ -82,6 +82,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
var seekAmount: Long = 20000 //ms
|
var seekAmount: Long = 20000 //ms
|
||||||
|
|
||||||
private var lastPauseTime: Long = 0 //ms
|
private var lastPauseTime: Long = 0 //ms
|
||||||
|
private var onSeekBack: Boolean = false
|
||||||
|
|
||||||
fun setCustomObjectListener(mylistener: MyCustomObjectListener) {
|
fun setCustomObjectListener(mylistener: MyCustomObjectListener) {
|
||||||
listener = mylistener
|
listener = mylistener
|
||||||
|
@ -416,6 +417,21 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
}
|
}
|
||||||
if (events.contains(Player.EVENT_IS_PLAYING_CHANGED)) {
|
if (events.contains(Player.EVENT_IS_PLAYING_CHANGED)) {
|
||||||
Log.d(tag, "EVENT IS PLAYING CHANGED")
|
Log.d(tag, "EVENT IS PLAYING CHANGED")
|
||||||
|
if (player.isPlaying) {
|
||||||
|
if (lastPauseTime > 0) {
|
||||||
|
if (onSeekBack) onSeekBack = false
|
||||||
|
else {
|
||||||
|
var backTime = calcPauseSeekBackTime()
|
||||||
|
if (backTime > 0) {
|
||||||
|
if (backTime >= mPlayer.currentPosition) backTime = mPlayer.currentPosition - 500
|
||||||
|
Log.d(tag, "SeekBackTime $backTime")
|
||||||
|
onSeekBack = true
|
||||||
|
seekBackward(backTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else lastPauseTime = System.currentTimeMillis()
|
||||||
if (listener != null) listener.onPlayingUpdate(player.isPlaying)
|
if (listener != null) listener.onPlayingUpdate(player.isPlaying)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,18 +538,11 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
Log.d(tag, "Already playing")
|
Log.d(tag, "Already playing")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (lastPauseTime > 0) {
|
|
||||||
var backTime = calcPauseSeekBackTime()
|
|
||||||
if (backTime >= mPlayer.currentPosition) backTime = mPlayer.currentPosition - 500
|
|
||||||
Log.d(tag, "SeekBackTime $backTime")
|
|
||||||
seekBackward(backTime)
|
|
||||||
}
|
|
||||||
mPlayer.play()
|
mPlayer.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pause() {
|
fun pause() {
|
||||||
mPlayer.pause()
|
mPlayer.pause()
|
||||||
lastPauseTime = System.currentTimeMillis()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun seekPlayer(time: Long) {
|
fun seekPlayer(time: Long) {
|
||||||
|
@ -556,6 +565,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
if (mPlayer.playbackState == Player.STATE_READY) {
|
if (mPlayer.playbackState == Player.STATE_READY) {
|
||||||
mPlayer.clearMediaItems()
|
mPlayer.clearMediaItems()
|
||||||
}
|
}
|
||||||
|
currentAudiobook?.id = ""
|
||||||
lastPauseTime = 0
|
lastPauseTime = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default {
|
||||||
seekLoading: false,
|
seekLoading: false,
|
||||||
onPlayingUpdateListener: null,
|
onPlayingUpdateListener: null,
|
||||||
onMetadataListener: null,
|
onMetadataListener: null,
|
||||||
noSyncUpdateTime: false
|
noSyncUpdateTime: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -101,7 +101,7 @@ export default {
|
||||||
MyNativeAudio.seekForward({ amount: '10000' })
|
MyNativeAudio.seekForward({ amount: '10000' })
|
||||||
},
|
},
|
||||||
sendStreamUpdate() {
|
sendStreamUpdate() {
|
||||||
this.$emit('updateTime', this.currentTime)
|
this.$emit('updateTime', this.currentTime)
|
||||||
},
|
},
|
||||||
setStreamReady() {
|
setStreamReady() {
|
||||||
this.readyTrackWidth = this.trackWidth
|
this.readyTrackWidth = this.trackWidth
|
||||||
|
@ -228,7 +228,7 @@ export default {
|
||||||
console.log('Same audiobook')
|
console.log('Same audiobook')
|
||||||
this.isPaused = !data.isPlaying
|
this.isPaused = !data.isPlaying
|
||||||
this.currentTime = Number((data.currentTime / 1000).toFixed(2))
|
this.currentTime = Number((data.currentTime / 1000).toFixed(2))
|
||||||
this.totalDuration = Number((data.duration / 1000).toFixed(2))
|
this.totalDuration = Number((data.duration / 1000).toFixed(2))
|
||||||
this.timeupdate()
|
this.timeupdate()
|
||||||
if (data.isPlaying) {
|
if (data.isPlaying) {
|
||||||
console.log('playing - continue')
|
console.log('playing - continue')
|
||||||
|
@ -333,9 +333,9 @@ export default {
|
||||||
this.setFromObj()
|
this.setFromObj()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this.stateName === 'ready_no_sync') || (this.stateName === 'buffering_no_sync')) this.noSyncUpdateTime = true
|
if ((this.stateName === 'ready_no_sync') || (this.stateName === 'buffering_no_sync')) this.noSyncUpdateTime = true
|
||||||
|
|
||||||
this.timeupdate()
|
this.timeupdate()
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
this.onPlayingUpdateListener = MyNativeAudio.addListener('onPlayingUpdate', this.onPlayingUpdate)
|
this.onPlayingUpdateListener = MyNativeAudio.addListener('onPlayingUpdate', this.onPlayingUpdate)
|
||||||
|
|
|
@ -154,6 +154,7 @@ export default {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.$server.socket.emit('close_stream')
|
this.$server.socket.emit('close_stream')
|
||||||
this.$store.commit('setStreamAudiobook', null)
|
this.$store.commit('setStreamAudiobook', null)
|
||||||
|
this.$server.stream = null
|
||||||
if (this.$refs.audioPlayerMini) {
|
if (this.$refs.audioPlayerMini) {
|
||||||
this.$refs.audioPlayerMini.terminateStream()
|
this.$refs.audioPlayerMini.terminateStream()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue