Reputation: 21
I am trying to figure out how to loop an MP3 using eclipse, what am I doing wrong?
mediaPlayer2.play();{
mediaPlayer2.setOnEndOfMedia(new Runnable() {
public void run() {
mediaPlayer2.seek(Duration.ZERO);
}
});
mediaPlayer2.play();
}
This should be the code, correct?
Upvotes: 1
Views: 3674
Reputation: 209705
The second call to play()
in your code is not in the run()
method of the endOfMedia
handler, so it won't get called when the media finishes.
But this is not the way to repeat a media player indefinitely anyway. Just do
mediaPlayer2.setCycleCount(MediaPlayer.INDEFINITE);
mediaPlayer2.play();
Upvotes: 2