[Android] Prevent NPE
Geoffrey Métais
git at videolan.org
Mon Sep 11 16:29:37 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Sep 11 16:29:13 2017 +0200| [458b384e62da95294837fc64b43f75802de91c17] | committer: Geoffrey Métais
Prevent NPE
> https://code.videolan.org/videolan/vlc-android/commit/458b384e62da95294837fc64b43f75802de91c17
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index ff0854154..128625412 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -912,12 +912,12 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
mUpdateMeta.wait();
} catch (InterruptedException ignored) {}
final MediaMetadataCompat metaData = mMediaSession.getController().getMetadata();
- title = metaData.getString(MediaMetadataCompat.METADATA_KEY_TITLE);
- artist = metaData.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST);
- album = metaData.getString(MediaMetadataCompat.METADATA_KEY_ALBUM);
- cover = coverOnLockscreen ?
- metaData.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART) :
- AudioUtil.readCoverBitmap(Uri.decode(mw.getArtworkMrl()), width);
+ title = metaData == null ? mw.getTitle() : metaData.getString(MediaMetadataCompat.METADATA_KEY_TITLE);
+ artist = metaData == null ? mw.getArtist() : metaData.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST);
+ album = metaData == null ? mw.getAlbum() : metaData.getString(MediaMetadataCompat.METADATA_KEY_ALBUM);
+ cover = coverOnLockscreen && metaData != null
+ ? metaData.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART)
+ : AudioUtil.readCoverBitmap(Uri.decode(mw.getArtworkMrl()), width);
}
if (cover == null || cover.isRecycled())
cover = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.ic_no_media);
More information about the Android
mailing list