From 7c87d795914d8133951a32378fe380126b2218e0 Mon Sep 17 00:00:00 2001 From: svd Date: Wed, 27 Oct 2021 11:34:50 +0800 Subject: [PATCH] add noSyncUpdateTime symbol, don't sync progress to srv before start playing --- .../audiobookshelf/app/PlayerNotificationService.kt | 6 ++++-- components/AudioPlayerMini.vue | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/android/app/src/main/java/com/audiobookshelf/app/PlayerNotificationService.kt b/android/app/src/main/java/com/audiobookshelf/app/PlayerNotificationService.kt index 6c15b91b..3c3276f9 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/PlayerNotificationService.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/PlayerNotificationService.kt @@ -388,11 +388,13 @@ class PlayerNotificationService : MediaBrowserServiceCompat() { }*/ currentAudiobook!!.hasPlayerLoaded = true - sendClientMetadata("ready") + if (lastPauseTime <= 0) sendClientMetadata("ready_no_sync") + else sendClientMetadata("ready") } if (mPlayer.playbackState == Player.STATE_BUFFERING) { Log.d(tag, "STATE_BUFFERING : " + mPlayer.currentPosition.toString()) - sendClientMetadata("buffering") + if (lastPauseTime <= 0) sendClientMetadata("buffering_no_sync") + else sendClientMetadata("buffering") } if (mPlayer.playbackState == Player.STATE_ENDED) { Log.d(tag, "STATE_ENDED") diff --git a/components/AudioPlayerMini.vue b/components/AudioPlayerMini.vue index 7661c3e6..fea9424a 100644 --- a/components/AudioPlayerMini.vue +++ b/components/AudioPlayerMini.vue @@ -74,7 +74,8 @@ export default { seekedTime: 0, seekLoading: false, onPlayingUpdateListener: null, - onMetadataListener: null + onMetadataListener: null, + noSyncUpdateTime: false } }, computed: { @@ -100,7 +101,7 @@ export default { MyNativeAudio.seekForward({ amount: '10000' }) }, sendStreamUpdate() { - this.$emit('updateTime', this.currentTime) + this.$emit('updateTime', this.currentTime) }, setStreamReady() { this.readyTrackWidth = this.trackWidth @@ -150,7 +151,8 @@ export default { } this.updateTimestamp() - this.sendStreamUpdate() + if (this.noSyncUpdateTime) this.noSyncUpdateTime = false + else this.sendStreamUpdate() var perc = this.currentTime / this.totalDuration var ptWidth = Math.round(perc * this.trackWidth) @@ -330,7 +332,9 @@ export default { this.setFromObj() } - this.timeupdate() + if ((this.stateName === 'ready_no_sync') || (this.stateName === 'buffering_no_sync')) this.noSyncUpdateTime = true + + this.timeupdate() }, init() { this.onPlayingUpdateListener = MyNativeAudio.addListener('onPlayingUpdate', this.onPlayingUpdate)