[Android] Position reported by Android Auto does not update correctly if we seek in the song.
Robert Stone
git at videolan.org
Wed Oct 14 07:43:02 CEST 2020
vlc-android | branch: 3.3.x | Robert Stone <rhstone at gmail.com> | Tue Oct 13 20:54:30 2020 -0700| [747ed696b49db029d8c23f454b403d28d7b87898] | committer: Robert Stone
Position reported by Android Auto does not update correctly if we seek in the song.
> https://code.videolan.org/videolan/vlc-android/commit/747ed696b49db029d8c23f454b403d28d7b87898
---
application/vlc-android/src/org/videolan/vlc/PlaybackService.kt | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 80df233e92..6132ea0d96 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -108,7 +108,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
internal lateinit var mediaSession: MediaSessionCompat
@Volatile
private var notificationShowing = false
-
+ private var lastTime = 0L
private var widget = 0
/**
* Last widget position update timestamp
@@ -169,6 +169,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
if (BuildConfig.DEBUG) Log.i(TAG, "MediaPlayer.Event.Playing")
executeUpdate()
publishState()
+ lastTime = time
audioFocusHelper.changeAudioFocus(true)
if (!wakeLock.isHeld) wakeLock.acquire()
showNotification()
@@ -182,7 +183,11 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
if (wakeLock.isHeld) wakeLock.release()
}
MediaPlayer.Event.EncounteredError -> executeUpdate()
- MediaPlayer.Event.PositionChanged -> if (widget != 0) updateWidgetPosition(event.positionChanged)
+ MediaPlayer.Event.PositionChanged -> {
+ if (time < 1000L && time < lastTime) publishState()
+ lastTime = time
+ if (widget != 0) updateWidgetPosition(event.positionChanged)
+ }
MediaPlayer.Event.ESAdded -> if (event.esChangedType == IMedia.Track.Type.Video && (playlistManager.videoBackground || !playlistManager.switchToVideo())) {
/* CbAction notification content intent: resume video or resume audio activity */
updateMetadata()
More information about the Android
mailing list