-
Bug
-
Resolution: Unresolved
-
P4
-
8u25
If the MediaPlayer reaches the specified number of cycle count, the sound stops playing (like expected) but the status property is not updated. Cause no sound is played anymore I would expect the status to change to stopped.
Code snippet to demonstrate the behaviour:
import javafx.embed.swing.JFXPanel;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
public class MediaPlayerStatusTest
{
public static void main(final String[] args) throws Exception
{
new MediaPlayerStatusTest();
}
public MediaPlayerStatusTest() throws Exception
{
// init
new JFXPanel();
String audioSource = getClass().getResource("sound1.wav").toURI().toString();
MediaPlayer player = new MediaPlayer(new Media(audioSource));
player.setCycleCount(3);
player.play();
// sleep required due to RT-31736
Thread.sleep(1000);
long duration = new Double(player.getMedia().getDuration().toMillis()).longValue();
System.out.println("Duration of the sound: " + duration);
System.out.println("Status (expected PLAYING): " + player.getStatus());
// sleep until the player has reached the specified cycle count
// and stopped playing the sound
Thread.sleep(duration * 5);
// sound has terminated. I would expect a changed status
System.out.println("Status (expected STOPPED): " + player.getStatus());
// try to play it again
player.play(); // this has no effect, cause stop has to be called first
}
}
Output:
Duration of the sound: 489
Status (expected PLAYING): PLAYING
Status (expected STOPPED): PLAYING
Code snippet to demonstrate the behaviour:
import javafx.embed.swing.JFXPanel;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
public class MediaPlayerStatusTest
{
public static void main(final String[] args) throws Exception
{
new MediaPlayerStatusTest();
}
public MediaPlayerStatusTest() throws Exception
{
// init
new JFXPanel();
String audioSource = getClass().getResource("sound1.wav").toURI().toString();
MediaPlayer player = new MediaPlayer(new Media(audioSource));
player.setCycleCount(3);
player.play();
// sleep required due to RT-31736
Thread.sleep(1000);
long duration = new Double(player.getMedia().getDuration().toMillis()).longValue();
System.out.println("Duration of the sound: " + duration);
System.out.println("Status (expected PLAYING): " + player.getStatus());
// sleep until the player has reached the specified cycle count
// and stopped playing the sound
Thread.sleep(duration * 5);
// sound has terminated. I would expect a changed status
System.out.println("Status (expected STOPPED): " + player.getStatus());
// try to play it again
player.play(); // this has no effect, cause stop has to be called first
}
}
Output:
Duration of the sound: 489
Status (expected PLAYING): PLAYING
Status (expected STOPPED): PLAYING
- relates to
-
JDK-8090017 MediaPlayer doesn't update status property
- Open