[Android] Read cover from artwork mrl

Geoffrey Métais git at videolan.org
Fri Apr 7 17:36:20 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Apr  7 11:36:10 2017 +0200| [dc36d886159b41c8d1728d9a77df34b71206e39f] | committer: Geoffrey Métais

Read cover from artwork mrl

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

 vlc-android/src/org/videolan/vlc/PlaybackService.java       | 10 +++++-----
 vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java |  3 ++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 14c06cd..824bf56 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -111,6 +111,8 @@ import java.util.Random;
 import java.util.Stack;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import static android.R.attr.width;
+
 public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVout.Callback {
 
     private static final String TAG = "VLC/PlaybackService";
@@ -865,7 +867,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
             String album = metaData.getString(MediaMetadataCompat.METADATA_KEY_ALBUM);
             Bitmap cover = coverOnLockscreen ?
                     metaData.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART) :
-                    AudioUtil.getCover(this, getCurrentMedia(), 512);
+                    AudioUtil.readCoverBitmap(Uri.decode(getCurrentMedia().getArtworkMrl()), width);
             if (cover == null)
                 cover = BitmapFactory.decodeResource(VLCApplication.getAppContext().getResources(), R.drawable.ic_no_media);
             Notification notification;
@@ -1295,7 +1297,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
                 .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, MediaUtils.getMediaAlbum(this, media))
                 .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, media.getLength());
         if (coverOnLockscreen) {
-            Bitmap cover = AudioUtil.getCover(this, media, 512);
+            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));
         }
@@ -1441,10 +1443,8 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
     private void updateWidgetCover() {
         Intent i = new Intent(VLCAppWidgetProvider.ACTION_WIDGET_UPDATE_COVER);
-
-        Bitmap cover = hasCurrentMedia() ? AudioUtil.getCover(this, getCurrentMedia(), 64) : null;
+        Bitmap cover = hasCurrentMedia() ? AudioUtil.readCoverBitmap(Uri.decode(getCurrentMedia().getArtworkMrl()), 64) : null;
         i.putExtra("cover", cover);
-
         sendBroadcast(i);
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index 53cb3ad..5e6e99b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -30,6 +30,7 @@ import android.content.IntentFilter;
 import android.content.pm.PackageManager;
 import android.graphics.Bitmap;
 import android.graphics.drawable.Drawable;
+import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Bundle;
@@ -588,7 +589,7 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
         } else  if (mService.hasMedia()){
             MediaWrapper mw = mService.getCurrentMediaWrapper();
             String display = MediaUtils.getMediaTitle(mw) + " - " + MediaUtils.getMediaReferenceArtist(MainTvActivity.this, mw);
-            Bitmap cover = AudioUtil.getCover(MainTvActivity.this, mw, VLCApplication.getAppResources().getDimensionPixelSize(R.dimen.grid_card_thumb_width));
+            Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(mw.getArtworkMrl()), VLCApplication.getAppResources().getDimensionPixelSize(R.dimen.grid_card_thumb_width));
             if (mNowPlayingCard == null) {
                 if (cover != null)
                     mNowPlayingCard = new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, cover);



More information about the Android mailing list