-
Bug
-
Resolution: Fixed
-
P3
-
fx2.1
-
Mac
I have a label which I want to bind up to the current time and total time for playing media like this:
Label timeLabel = new Label();
Media media = new Media(....):
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
timeLabel.textProperty().bind(Bindings.concat("Time: ",mediaPlayer.currentTimeProperty()," Total: ", media.durationProperty()));
This should work but either mediaPlayer.currentTimeProperty or media.durationProperty is not being set on the FX thread so I get a Exception:
Exception in thread "Timer-0" java.lang.IllegalStateException: Not on FX application thread; currentThread = Timer-0
at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:218)
at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:360)
at javafx.scene.Parent$1.onProposedChange(Parent.java:224)
at com.sun.javafx.collections.VetoableObservableList.setAll(VetoableObservableList.java:70)
at com.sun.javafx.collections.ObservableListWrapper.setAll(ObservableListWrapper.java:232)
at com.sun.javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:544)
at com.sun.javafx.scene.control.skin.LabeledSkinBase.handleControlPropertyChanged(LabeledSkinBase.java:208)
at com.sun.javafx.scene.control.skin.SkinBase$4.changed(SkinBase.java:263)
at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:67)
at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:64)
at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:80)
at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:87)
at javafx.beans.property.StringPropertyBase.access$100(StringPropertyBase.java:26)
Label timeLabel = new Label();
Media media = new Media(....):
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
timeLabel.textProperty().bind(Bindings.concat("Time: ",mediaPlayer.currentTimeProperty()," Total: ", media.durationProperty()));
This should work but either mediaPlayer.currentTimeProperty or media.durationProperty is not being set on the FX thread so I get a Exception:
Exception in thread "Timer-0" java.lang.IllegalStateException: Not on FX application thread; currentThread = Timer-0
at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:218)
at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:360)
at javafx.scene.Parent$1.onProposedChange(Parent.java:224)
at com.sun.javafx.collections.VetoableObservableList.setAll(VetoableObservableList.java:70)
at com.sun.javafx.collections.ObservableListWrapper.setAll(ObservableListWrapper.java:232)
at com.sun.javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:544)
at com.sun.javafx.scene.control.skin.LabeledSkinBase.handleControlPropertyChanged(LabeledSkinBase.java:208)
at com.sun.javafx.scene.control.skin.SkinBase$4.changed(SkinBase.java:263)
at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:67)
at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:64)
at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:80)
at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:87)
at javafx.beans.property.StringPropertyBase.access$100(StringPropertyBase.java:26)
- relates to
-
JDK-8115574 MediaPlayer's currentTime property is not updated on the JavaFX application thread
- Closed
-
JDK-8117838 MediaPlayer's status property is not updated on the JavaFX application thread
- Closed