Home » Android » Edit ID3 Tags of mp3

Edit ID3 Tags of mp3

Posted by: admin November 1, 2017 Leave a comment

Questions:

I am trying to edit audio-files (mp3) using an App.
I want to change things like artist, album, title, cover, etc.

However, I haven’t found a working library to use in this case. I recently tried MyID3 (Android Port) according to this question: How to get and set (change) ID3 tag (metadata) of audio files?

This is my code:

File mp3 = new File("/storage/17E9-1112/test/test.mp3");
if (mp3.exists()) {
    System.out.println("exists");
}

//check for metadata
MusicMetadataSet src_set = null;
try {
    src_set = new MyID3().read(mp3);
} catch (IOException e1) {
    e1.printStackTrace();
}

if (src_set == null) {
    System.out.println("no metadata");
} else {
    try{
        IMusicMetadata metadata = src_set.getSimplified();
        String artist = metadata.getArtist();
        String album = metadata.getAlbum();
        System.out.println(artist);
        System.out.println(album);
    }catch (Exception e) {
        e.printStackTrace();
    }
}

The system prints out exists, meanign the file should exist but I get this error:

java.io.FileNotFoundException: /storage/17E9-1112/test/test.mp3 (Permission denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:146)
at org.cmc.music.myid3.MyID3.readID3v1(MyID3.java:474)
at org.cmc.music.myid3.MyID3.read(MyID3.java:436)
at org.cmc.music.myid3.MyID3.read(MyID3.java:411)
at thejetstream.de.mp3tagedit.Main.test(Main.java:67)
at thejetstream.de.mp3tagedit.Main$1.onClick(Main.java:40)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22265)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

I also added the permissions to the AndroidManifest.xml:

android.permission.READ_EXTERNAL_STORAGE
android.permission.WRITE_EXTERNAL_STORAGE

What is the problem with this code? Or is there a better library (that works on android) that can read and write ID3 tags?

Answers: