0

I need to get thubnail of audio file by url.

I found how I can do it for files in internal memory.

But how I can do it for remote audio files by URL? I have URL of file and I can get byte[] of file.

For remote images I do it this way:

content is byte[] from server.

bitmap = Glide
         .with(context)
         .asBitmap()
         .load(content)
         .submit(size.getWidth(), size.getHeight())
         .get();
Zoe
  • 27,060
  • 21
  • 118
  • 148
Ivan
  • 113
  • 1
  • 1
  • 7
  • If you are referring to album artwork, then this might be of use to you: https://stackoverflow.com/questions/42482390/how-can-get-album-art-of-song-from-url – Janaaaa Jul 17 '18 at 16:15

1 Answers1

0

I didn't find how to do it with the help of Glide. And I did it using this:

Bitmap bitmap = null;
MediaMetadataRetriever mediaMetadataRetriever = null;
byte[] data;

try {
    mediaMetadataRetriever = new MediaMetadataRetriever();
    mediaMetadataRetriever.setDataSource(url.toString(), new HashMap<String, String>());
    data = mediaMetadataRetriever.getEmbeddedPicture();
    if (data != null) {
            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
        }
    } catch (Exception e) {
        Log.e(TAG, " ", e);
    } finally {
        if (mediaMetadataRetriever != null) {
            mediaMetadataRetriever.release();
        }
    }
    return bitmap;
}
Ivan
  • 113
  • 1
  • 1
  • 7