Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8117838

MediaPlayer's status property is not updated on the JavaFX application thread

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0.2
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Environment:

      Mac OS X 10.7 and JavaFX 2.1 beta, Windows 7 with Java 6 u29 and JavaFX 2.0.2.

      Description

      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();
        }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              diversonjfx Dean Iverson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: