[Android] Check player length info on meta update

Geoffrey Métais git at videolan.org
Wed Dec 6 14:33:28 CET 2017


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Dec  5 10:56:28 2017 +0100| [c977de6d5de533e5ba88649ed18fad08805d4e23] | committer: Geoffrey Métais

Check player length info on meta update

Media length can be null at this time

(cherry picked from commit 962d25216677d2510280cc6c2bd86d7884244bee)

> https://code.videolan.org/videolan/vlc-android/commit/c977de6d5de533e5ba88649ed18fad08805d4e23
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 5889de707..5894ad37d 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1401,8 +1401,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
     protected void updateMetadata() {
         final MediaWrapper media = getCurrentMedia();
-        if (media == null)
-            return;
+        if (media == null) return;
         if (mMediaSession == null)
             initMediaSession();
         final Context ctx = this;
@@ -1412,8 +1411,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
                 synchronized (ExecutorHolder.updateMeta) {
                     ExecutorHolder.updateMeta.set(true);
                 }
-                if (media == null)
-                    return;
+                if (media == null) return;
                 String title = media.getNowPlaying();
                 if (title == null)
                     title = media.getTitle();
@@ -1426,9 +1424,9 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
                         .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, MediaUtils.getMediaArtist(ctx, media))
                         .putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, MediaUtils.getMediaReferenceArtist(ctx, media))
                         .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, MediaUtils.getMediaAlbum(ctx, media))
-                        .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, media.getLength());
+                        .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, getLength());
                 if (coverOnLockscreen) {
-                    Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(media.getArtworkMrl()), 512);
+                    final Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(media.getArtworkMrl()), 512);
                     if (cover != null && cover.getConfig() != null) //In case of format not supported
                         bob.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, cover.copy(cover.getConfig(), false));
                 }



More information about the Android mailing list