-
Bug
-
Resolution: Unresolved
-
P4
-
7u25
-
Ubuntu 12.04
javafx.version: 2.2.25
java.vm.version: 23.25-b01
java.vm.vendor: Oracle Corporation
java.vm.name: Java HotSpot(TM) 64-Bit Server VM
java.runtime.version: 1.7.0_25-b15
javafx.runtime.version: 2.2.25-b15
os.arch: amd64
os.name: Linux
sun.jnu.encoding: UTF-8
os.version: 3.2.0-49-generic
java.specification.version: 1.7
java.version: 1.7.0_25Ubuntu 12.04 javafx.version: 2.2.25 java.vm.version: 23.25-b01 java.vm.vendor: Oracle Corporation java.vm.name: Java HotSpot(TM) 64-Bit Server VM java.runtime.version: 1.7.0_25-b15 javafx.runtime.version: 2.2.25-b15 os.arch: amd64 os.name: Linux sun.jnu.encoding: UTF-8 os.version: 3.2.0-49-generic java.specification.version: 1.7 java.version: 1.7.0_25
Try this:
import java.io.File;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.stage.Stage;
public class BugReportMain extends Application {
public static void main(String... args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
final File sourceFile = new File("/media/music/musik/Pop/Abba - Gimme Gimme Gimme.mp3");
final Media media = new Media(sourceFile.toURI().toURL().toString());
final MediaPlayer player = new MediaPlayer(media);
// force the player to do what it's there for
player.play();
System.out.println("current status: " + player.getStatus());
player.stop();
System.out.println("current status: " + player.getStatus());
Platform.exit();
}
}
(Let the source file point to any of your mp3 file that is valid).
At least on my system, the status of the media player is not updated, it always tells me that the status is UNKNOWN.
If I add a change listener on the status property, the status is not even set to UNKNOWN, instead it stays null:
import java.io.File;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaPlayer.Status;
import javafx.stage.Stage;
public class BugReportMain extends Application {
public static void main(String... args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
final File sourceFile = new File("/media/music/musik/Pop/Abba - Gimme Gimme Gimme.mp3");
final Media media = new Media(sourceFile.toURI().toURL().toString());
final MediaPlayer player = new MediaPlayer(media);
player.statusProperty().addListener(new ChangeListener<Status>() {
@Override
public void changed(ObservableValue<? extends Status> observable, Status oldValue, Status newValue) {
System.out.println("status changed: " + oldValue + " -> " + newValue);
}
});
// force the player to do what it's there for
player.play();
System.out.println("current status: " + player.getStatus());
player.stop();
System.out.println("current status: " + player.getStatus());
Platform.exit();
}
}
I would expect the media player to react in a different way.
1. Don't forget to set internal status if there is a change listener registered (IMO, this shouldn't play a role)
2. On the play / stop / pause calls, update the status property
Maybe this behaviour influences #RT-31627 or vice versa.
import java.io.File;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.stage.Stage;
public class BugReportMain extends Application {
public static void main(String... args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
final File sourceFile = new File("/media/music/musik/Pop/Abba - Gimme Gimme Gimme.mp3");
final Media media = new Media(sourceFile.toURI().toURL().toString());
final MediaPlayer player = new MediaPlayer(media);
// force the player to do what it's there for
player.play();
System.out.println("current status: " + player.getStatus());
player.stop();
System.out.println("current status: " + player.getStatus());
Platform.exit();
}
}
(Let the source file point to any of your mp3 file that is valid).
At least on my system, the status of the media player is not updated, it always tells me that the status is UNKNOWN.
If I add a change listener on the status property, the status is not even set to UNKNOWN, instead it stays null:
import java.io.File;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaPlayer.Status;
import javafx.stage.Stage;
public class BugReportMain extends Application {
public static void main(String... args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
final File sourceFile = new File("/media/music/musik/Pop/Abba - Gimme Gimme Gimme.mp3");
final Media media = new Media(sourceFile.toURI().toURL().toString());
final MediaPlayer player = new MediaPlayer(media);
player.statusProperty().addListener(new ChangeListener<Status>() {
@Override
public void changed(ObservableValue<? extends Status> observable, Status oldValue, Status newValue) {
System.out.println("status changed: " + oldValue + " -> " + newValue);
}
});
// force the player to do what it's there for
player.play();
System.out.println("current status: " + player.getStatus());
player.stop();
System.out.println("current status: " + player.getStatus());
Platform.exit();
}
}
I would expect the media player to react in a different way.
1. Don't forget to set internal status if there is a change listener registered (IMO, this shouldn't play a role)
2. On the play / stop / pause calls, update the status property
Maybe this behaviour influences #RT-31627 or vice versa.
- relates to
-
JDK-8089214 MediaPlayer doesn't update status property when end of media is reached
- Open