add noSyncUpdateTime symbol, don't sync progress to srv before start playing

This commit is contained in:
svd
2021-10-27 11:34:50 +08:00
parent ab8e06283f
commit 7c87d79591
2 changed files with 12 additions and 6 deletions
@@ -388,11 +388,13 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
}*/ }*/
currentAudiobook!!.hasPlayerLoaded = true currentAudiobook!!.hasPlayerLoaded = true
sendClientMetadata("ready") if (lastPauseTime <= 0) sendClientMetadata("ready_no_sync")
else sendClientMetadata("ready")
} }
if (mPlayer.playbackState == Player.STATE_BUFFERING) { if (mPlayer.playbackState == Player.STATE_BUFFERING) {
Log.d(tag, "STATE_BUFFERING : " + mPlayer.currentPosition.toString()) 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) { if (mPlayer.playbackState == Player.STATE_ENDED) {
Log.d(tag, "STATE_ENDED") Log.d(tag, "STATE_ENDED")
+8 -4
View File
@@ -74,7 +74,8 @@ export default {
seekedTime: 0, seekedTime: 0,
seekLoading: false, seekLoading: false,
onPlayingUpdateListener: null, onPlayingUpdateListener: null,
onMetadataListener: null onMetadataListener: null,
noSyncUpdateTime: false
} }
}, },
computed: { computed: {
@@ -100,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
@@ -150,7 +151,8 @@ export default {
} }
this.updateTimestamp() this.updateTimestamp()
this.sendStreamUpdate() if (this.noSyncUpdateTime) this.noSyncUpdateTime = false
else this.sendStreamUpdate()
var perc = this.currentTime / this.totalDuration var perc = this.currentTime / this.totalDuration
var ptWidth = Math.round(perc * this.trackWidth) var ptWidth = Math.round(perc * this.trackWidth)
@@ -330,7 +332,9 @@ export default {
this.setFromObj() this.setFromObj()
} }
this.timeupdate() if ((this.stateName === 'ready_no_sync') || (this.stateName === 'buffering_no_sync')) this.noSyncUpdateTime = true
this.timeupdate()
}, },
init() { init() {
this.onPlayingUpdateListener = MyNativeAudio.addListener('onPlayingUpdate', this.onPlayingUpdate) this.onPlayingUpdateListener = MyNativeAudio.addListener('onPlayingUpdate', this.onPlayingUpdate)