use getAndroidMediaIds for cover and mirrorlink
This commit is contained in:
parent
7d90334867
commit
cb6b824e05
@ -28,7 +28,6 @@ import android.graphics.Bitmap.CompressFormat;
|
|||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -445,15 +444,9 @@ public class CoverCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inputStream == null && (CoverCache.mCoverLoadMode & CoverCache.COVER_MODE_ANDROID) != 0) {
|
if (inputStream == null && (CoverCache.mCoverLoadMode & CoverCache.COVER_MODE_ANDROID) != 0) {
|
||||||
long albumId = -1;
|
|
||||||
ContentResolver res = mContext.getContentResolver();
|
ContentResolver res = mContext.getContentResolver();
|
||||||
|
long[] androidIds = MediaUtils.getAndroidMediaIds(mContext, song);
|
||||||
// Lookup the album id assigned to this path in the android media store
|
long albumId = androidIds[1];
|
||||||
Cursor cursor = res.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[]{ MediaStore.Audio.Media.ALBUM_ID }, MediaStore.Audio.Media.DATA+"=?", new String[] { song.path }, null);
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
albumId = cursor.getLong(0);
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
|
|
||||||
if (albumId != -1) {
|
if (albumId != -1) {
|
||||||
// now we can query for the album art path if we found an album id
|
// now we can query for the album art path if we found an album id
|
||||||
|
@ -20,7 +20,6 @@ package ch.blinkenlights.android.vanilla;
|
|||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
@ -755,18 +754,22 @@ public class MirrorLinkMediaBrowserService extends MediaBrowserService
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(song != null) {
|
if(song != null) {
|
||||||
|
long[] androidIds = MediaUtils.getAndroidMediaIds(getApplicationContext(), song);
|
||||||
|
long songId = androidIds[0];
|
||||||
|
if (songId != -1) {
|
||||||
MediaMetadata metadata = new MediaMetadata.Builder()
|
MediaMetadata metadata = new MediaMetadata.Builder()
|
||||||
.putString(MediaMetadata.METADATA_KEY_MEDIA_ID, Long.toString(song.id))
|
.putString(MediaMetadata.METADATA_KEY_MEDIA_ID, Long.toString(songId))
|
||||||
.putString(MediaMetadata.METADATA_KEY_ALBUM, song.album)
|
.putString(MediaMetadata.METADATA_KEY_ALBUM, song.album)
|
||||||
.putString(MediaMetadata.METADATA_KEY_ARTIST, song.artist)
|
.putString(MediaMetadata.METADATA_KEY_ARTIST, song.artist)
|
||||||
.putLong(MediaMetadata.METADATA_KEY_DURATION, song.duration)
|
.putLong(MediaMetadata.METADATA_KEY_DURATION, song.duration)
|
||||||
.putString(MediaMetadata.METADATA_KEY_ALBUM_ART_URI, "content://media/external/audio/media/" + Long.toString(song.id) + "/albumart")
|
.putString(MediaMetadata.METADATA_KEY_ALBUM_ART_URI, "content://media/external/audio/media/" + Long.toString(songId) + "/albumart")
|
||||||
.putString(MediaMetadata.METADATA_KEY_TITLE, song.title)
|
.putString(MediaMetadata.METADATA_KEY_TITLE, song.title)
|
||||||
.putLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER, song.trackNumber)
|
.putLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER, song.trackNumber)
|
||||||
.build();
|
.build();
|
||||||
mSession.setMetadata(metadata);
|
mSession.setMetadata(metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onPositionInfoChanged() {
|
public void onPositionInfoChanged() {
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_STATE, null));
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_STATE, null));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user