-
Bug
-
Resolution: Fixed
-
P3
-
fx2.0.2
-
Mac OS X 10.7 and JavaFX 2.1 beta, Windows 7 with Java 6 u29 and JavaFX 2.0.2.
Any attempt to bind scene graph node properties to the status property either directly or in a binding expression (for example, to control the state of a media player's play/pause button) will result in exceptions or strange bugs due to the changes not happening on the JavaFX application thread.
This example code shows that these updates happen on the JFXMedia Player EventQueueThread rather than the app thread.
public class StatusUpdates extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
System.out.println("JavaFX version: "+VersionInfo.getRuntimeVersion());
Media m = new Media("http://traffic.libsyn.com/dickwall/JavaPosse373.mp3");
final MediaPlayer mp = new MediaPlayer(m);
mp.statusProperty().addListener(new ChangeListener<MediaPlayer.Status>() {
@Override
public void changed(ObservableValue<? extends MediaPlayer.Status> observable,
MediaPlayer.Status oldValue, MediaPlayer.Status newValue) {
System.out.println("status changed from "+oldValue+" to "+newValue+
" on "+Thread.currentThread().getName());
}
});
// This causes problems
// Label label = new Label();
// label.textProperty().bind(Bindings.convert(mp.statusProperty()));
final Scene scene = new Scene(new Group(), 200, 200);
primaryStage.setScene(scene);
primaryStage.setTitle("Status Update Bug");
primaryStage.show();
mp.play();
}
}
This example code shows that these updates happen on the JFXMedia Player EventQueueThread rather than the app thread.
public class StatusUpdates extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
System.out.println("JavaFX version: "+VersionInfo.getRuntimeVersion());
Media m = new Media("http://traffic.libsyn.com/dickwall/JavaPosse373.mp3");
final MediaPlayer mp = new MediaPlayer(m);
mp.statusProperty().addListener(new ChangeListener<MediaPlayer.Status>() {
@Override
public void changed(ObservableValue<? extends MediaPlayer.Status> observable,
MediaPlayer.Status oldValue, MediaPlayer.Status newValue) {
System.out.println("status changed from "+oldValue+" to "+newValue+
" on "+Thread.currentThread().getName());
}
});
// This causes problems
// Label label = new Label();
// label.textProperty().bind(Bindings.convert(mp.statusProperty()));
final Scene scene = new Scene(new Group(), 200, 200);
primaryStage.setScene(scene);
primaryStage.setTitle("Status Update Bug");
primaryStage.show();
mp.play();
}
}
- relates to
-
JDK-8115574 MediaPlayer's currentTime property is not updated on the JavaFX application thread
- Closed
-
JDK-8127074 MediaPlayer or Media updating properties on wrong thread.
- Closed