mpatric / mp3agic

A java library for reading mp3 files and reading / manipulating the ID3 tags (ID3v1 and ID3v2.2 through ID3v2.4).
MIT License
1.2k stars 311 forks source link

Error using mp3agic library in Android Studio #176

Open JeanSantosReyes opened 4 years ago

JeanSantosReyes commented 4 years ago

I manage to rename the song file, using the File class it renames me perfectly, but it does not show the change in the listview even though I update the adapter and the arraylist, so I opted to use mp3agic to change the labels, but it shows me an error. Error image

This is the code to rename that I use

public void Rename(int position, String newFilename){
    try {
        File file = new File(resultados.get(position).getArchivo());
        Mp3File mp3File = new Mp3File(file.getPath());
        //Toast.makeText(MainActivity.this, "ID3v1?: "+ (mp3File.hasId3v1Tag() ? "YES" : "NO"), Toast.LENGTH_SHORT).show();
        ID3v1 id3v1Tag;
        if (mp3File.hasId3v1Tag()) {
            id3v1Tag =  mp3File.getId3v1Tag();
            //Toast.makeText(MainActivity.this, ""+id3v1Tag.getTitle(), Toast.LENGTH_SHORT).show();
        }else {
            // mp3 does not have an ID3v1 tag, let's create one..
            id3v1Tag = new ID3v1Tag();
            mp3File.setId3v1Tag(id3v1Tag);
            //Toast.makeText(MainActivity.this, "tag was created", Toast.LENGTH_SHORT).show();
        }
        id3v1Tag.setTitle(resultados.get(position).getNombre());
        id3v1Tag.setArtist(resultados.get(position).getArtista());
        mp3File.save(newFilename);
    } catch (IOException e) {
        Toast.makeText(MainActivity.this, "IOException: "+e, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    } catch (UnsupportedTagException e) {
        Toast.makeText(MainActivity.this, "UnsupportedTagException: "+e, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    } catch (InvalidDataException e) {
        Toast.makeText(MainActivity.this, "InvalidDataException: "+e, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    } catch (NotSupportedException e) {
        Toast.makeText(MainActivity.this, "NotSupportedException: "+e, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
}

I need help. Thanks.

mpatric commented 3 years ago

Can you provide a full stack trace? It would be easier to see what's going on

joe-vettek commented 2 years ago

W/System.err: com.mpatric.mp3agic.InvalidDataException: No mpegs frames found at com.mpatric.mp3agic.Mp3File.init(Mp3File.java:97) at com.mpatric.mp3agic.Mp3File.(Mp3File.java:58) at com.mpatric.mp3agic.Mp3File.(Mp3File.java:45)

joe-vettek commented 2 years ago

image

joe-vettek commented 2 years ago

I may understand that what I opened is actually an m4a file, although it is marked as MP3 file.

joe-vettek commented 1 year ago

Here is a supplement. For some mp3 suffix files that are actually m4a files, they may be read successfully and then become unplayable, which is worth noting.