My goal is to download an mp3 file and update its information in the MediaStore.
The problem is when my DownloadManager finishes, the MediaStore still might not have been updated with the new file. This means when I go to update the MediaStore with the goal Artist, Album, etc. ContentValues there is no MediaStore entry to update. I have tried manually inserting the ContentValues into the MediaStore as well, but this does not appear to work either.
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
/*insert or updating the MediaStore is not working here
updating doesn't work because there is no MediaStore entry to update
insert doesn't appear to do anything...*/
ContentValues values = new ContentValues();
values.put(MediaStore.Audio.Media.ARTIST, "artist");
values.put(MediaStore.Audio.Media.ALBUM, "album");
values.put(MediaStore.Audio.Media.DATA, "/storage/emulated/0/Music/filename");
values.put(MediaStore.Audio.Media.IS_MUSIC, true);
values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/mp3");
values.put(MediaStore.Audio.Media.TITLE, "title");
getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values);
}
}
Aucun commentaire:
Enregistrer un commentaire