Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using mp3agic library in Android Studio #176

Open
JeanSantosReyes opened this issue Jun 25, 2020 · 5 comments
Open

Error using mp3agic library in Android Studio #176

JeanSantosReyes opened this issue Jun 25, 2020 · 5 comments

Comments

@JeanSantosReyes
Copy link

JeanSantosReyes commented Jun 25, 2020

  • If the song has meta-data, it allows me to rename a song.
  • But if it doesn't have meta-data, it doesn't allow me to rename a song. Error image

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.

@JeanSantosReyes JeanSantosReyes changed the title Any example project using mp3agic library in Android Studio? Error using mp3agic library in Android Studio Jun 25, 2020
@mpatric
Copy link
Owner

mpatric commented Sep 19, 2020

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

@joe-vettek
Copy link

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
Copy link

image

@joe-vettek
Copy link

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

@joe-vettek
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants