diff --git a/src/ch/blinkenlights/android/vanilla/MediaUtils.java b/src/ch/blinkenlights/android/vanilla/MediaUtils.java index 645859fa..599b7d7a 100644 --- a/src/ch/blinkenlights/android/vanilla/MediaUtils.java +++ b/src/ch/blinkenlights/android/vanilla/MediaUtils.java @@ -562,6 +562,25 @@ public class MediaUtils { return matrixCursor; } + /** + * Returns the id's used by Androids native media database for given song + * + * @param context the context to use + * @param song the song to query + * @return long { song_id, album_id, artist_id } - all set to -1 on error + */ + public static long[] getAndroidMediaIds(Context context, Song song) { + long[] result = { -1, -1, -1 }; + String[] projection = new String[]{ MediaStore.Audio.Media._ID, MediaStore.Audio.Media.ALBUM_ID, MediaStore.Audio.Media.ARTIST_ID }; + Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, MediaStore.Audio.Media.DATA+"=?", new String[] { song.path }, null); + if (cursor.moveToFirst()) { + for (int i=0; i