Reputation: 111
I am using the jAudioTagger library to edit metadata of songs from my music player. The function to edit the tags is:
save = (Button) findViewById(R.id.save);
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
File src = new File(filepath);
songName=song.getText().toString();
artistName=artist.getText().toString();
albumName=album.getText().toString();
try{
TagOptionSingleton.getInstance().setAndroid(true);
AudioFile f = AudioFileIO.read(src);
f.setTag(new ID3v23Tag());
Tag tag=f.getTag();
tag.setField(FieldKey.TITLE,songName);
tag.setField(FieldKey.ARTIST,artistName);
tag.setField(FieldKey.ALBUM,albumName);
f.commit();
Toast.makeText(getApplicationContext(),"Done",Toast.LENGTH_SHORT).show();
}catch (Exception e){
e.printStackTrace();
}
}
});
However, after updating the tags, the change is not reflected anywhere. Even after refreshing my music library, the changes are not shown. How do I update the MediaStore to reflect the changes I've made to the tags so that all music players have access to the edited tags?
Upvotes: 0
Views: 518
Reputation: 11
Instead of audioFile.commit();
use AudioFileIO.write(audioFile);
If it doesn't work, use this method to scan your media
private void scanMedia(String path) {
File file = new File(path);
Uri uri = Uri.fromFile(file);
Intent scanFileIntent = new Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
getContext().sendBroadcast(scanFileIntent);
}
Upvotes: 1