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 310 forks source link

Error with Metatag bpm - Floating Decimal Error #185

Open MaWiLi opened 3 years ago

MaWiLi commented 3 years ago

Problems to set the result ob getBpm() into an int variable.

Exception in thread "main" java.lang.NumberFormatException: For input string: "0 Bpm" at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054) at java.base/jdk.internal.math.FloatingDecimal.parseFloat(FloatingDecimal.java:122) at java.base/java.lang.Float.parseFloat(Float.java:455) at com.mpatric.mp3agic.AbstractID3v2Tag.getBPM(AbstractID3v2Tag.java:600)

jmizv commented 3 years ago

Hi @MaWiLi

have you seen this test case?

  @Test
    public void shouldStoreAndRetrieveBPM() throws Exception {
        final ID3v22Tag id3tag = new ID3v22Tag();
        final int bpm = 8 * 44100;
        id3tag.setBPM(bpm);
        final byte[] bytes = id3tag.toBytes();
        final ID3v22Tag newId3tag = new ID3v22Tag(bytes);
        assertEquals(bpm, newId3tag.getBPM());
    }

It works fine. What is the code you use to produce the above exception?