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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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);
回答2:
I may be wrong, but for the boolean it is : Status.READY