i want my mp3 file repeat again after it finished . but i\'m unable to create a loop to play my file repeatedly (i used this code but only it plays first second of my file a
for avoiding the suddenly stopping, you must :
a.setOnReady(new Runnable() {
@Override
public void run() {
a.play();
}
});
It works for me.
i found my solution i used setOnEndOfMedia method :
URL resource = getClass().getResource("abcd.mp3");
MediaPlayer a =new MediaPlayer(new Media(resource.toString()));
a.setOnEndOfMedia(new Runnable() {
public void run() {
a.seek(Duration.ZERO);
}
});
a.play();