0

I'm trying to create a basic Media Player in JavaFX. I finally made it possible to display the album cover based on the metadata on the file.

However on some songs it doesn't show anything, even if I know that there is an album cover.

Here theres no problem:

two muppets

two muppets

However when I select another file it just looks like this:

two muppets

two muppets

I swear the only thing I'm changing is the name of the song. Both of the files are formatted in MP3 and have a 500x500 jpg as album cover. The song plays succesfully. Meaning that the file exist. But no album cover

the me variable is the Media which contains the file.

This is the method I'm using to display the album cover in the program:

private void displayAlbumCover (){

    // Will start to show a blank CD
    File file = new File("src/sample/images/blank_cd.jpeg");

    Image image = new Image(file.toURI().toString());

    albumCoverView.setImage(image);


    // However if an album cover is found in the meta-data it will be displayed
    ObservableMap<String,Object> meta_data=me.getMetadata();

    meta_data.addListener((MapChangeListener<String, Object>) ch -> {

        if(ch.wasAdded()){

            String key=ch.getKey();
            Object value=ch.getValueAdded();

            if (key.equals("image")){

                // If there's an album cover in the metadata it will be displayed
                albumCoverView.setImage((Image)value);

                System.out.println("Found album cover");

            }
        }
    });

}
  • 1
    [What is a debugger and how can it help me diagnose problems?](https://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) – Cardinal System Jan 08 '19 at 23:17

1 Answers1

0

Okay I've tried debugging, and this is what I get:

enter image description here

The one above is the one that works fine.

enter image description here

But this one does not. Can you see something based on the information, that I gave you?