[英]How to tell if MediaPlayer is playing?
How can I tell if javafx.scene.media.MediaPlayer is playing? 如何判断javafx.scene.media.MediaPlayer是否在播放? 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.
我正在将该软件安装在ARM CPU上,因此我试图使此代码尽可能地简化。 I am only going to use this framework to play music files and primarily MP3s.
我只会使用此框架来播放音乐文件,主要是MP3。 Any suggestions on how I can tell if the player is playing music with this or a different library?
关于如何判断播放器正在使用该音乐库还是其他音乐库的任何建议?
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);
我可能是错的,但对于布尔值来说是:Status.READY
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.