Question

How can I tell if javafx.scene.media.MediaPlayer is playing? Preferably without any external imports or additions to the build path. If this is not possible, are there any libraries that I can use that are self-contained? I am installing this software on an ARM CPU so I am trying to make this code as minimalist as possible. I am only going to use this framework to play music files and primarily MP3s. Any suggestions on how I can tell if the player is playing music with this or a different library?

Was it helpful?

Solution

if I understood:

mediaPlayer.setOnEndOfMedia(new Runnable() {
    @Override
    public void run() {
        playing = false;
    }
});

mediaPlayer.setOnReady(new Runnable() {
    @Override
    public void run() {
        mediaPlayer.play();
        playing = true;
    }
});

Or

boolean playing = mediaPlayer.getStatus().equals(Status.PLAYING);

OTHER TIPS

I may be wrong, but for the boolean it is : Status.READY

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top