-
Bug
-
Resolution: Incomplete
-
P4
-
None
-
jfx19
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Accessing a file from internet using the media player may sometimes result in an error.
This happen from time to time. Trying again, same file, may work again.
Maybe is some caching of the data stream, or some other issuse.
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@5df01b5c] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
at javafx.scene.media.MediaException.getMediaException(MediaException.java:161)
at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2624)
at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:692)
at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:426)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I use the code below:
private void loadVideo(MediaEntry mediaEntry, boolean autoPlay ) {
try {
final MediaPlayer pl = mediaView.getMediaPlayer();
if (pl != null) {
pl.stop();
pl.dispose();
pl.volumeProperty().unbind();
mediaView.setMediaPlayer(null);
}
progressBar.setVisible(true);
progressBar.bar.setProgress(ProgressBar.INDETERMINATE_PROGRESS);
playButton.setDisable(true);
playButton.setGraphic( BootstrapIcons.play_fill.glyph("glyph-blue", "glyph-24"));
final MediaPlayer mediaPlayer = new MediaPlayer( new Media(mediaEntry.getLocation()));
mediaPlayer.currentTimeProperty().addListener((o1, p1, duration) -> setProgressBarText(mediaPlayer, (long) duration.toSeconds()));
mediaPlayer.setOnReady(() ->
Platform.runLater(() -> {
playButton.setDisable( false );
if (autoPlay) {
mediaPlayer.play();
playButton.setGraphic(pauseLabel);
} else {
playButton.setGraphic(playLabel);
progressBar.bar.progressProperty().set(0d);
setProgressBarText(mediaPlayer, 0);
}
})
);
mediaView.setMediaPlayer(mediaPlayer);
mediaPlayer.volumeProperty().bind(volumeBar.progressProperty());
playButton.setDisable(false);
} catch ( Throwable ex ) {
progressBar.setVisible(false);
rx.showError(getScene(), ex.getLocalizedMessage());
}
}
private static class MediaEntry {
public final String name, url;
MediaEntry(String name, String url){
this.name = name;
this.url = url;
}
public String getLocation(){
return url;
}
@Override
public String toString() {
return name;
}
}
FREQUENCY : often
Accessing a file from internet using the media player may sometimes result in an error.
This happen from time to time. Trying again, same file, may work again.
Maybe is some caching of the data stream, or some other issuse.
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@5df01b5c] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
at javafx.scene.media.MediaException.getMediaException(MediaException.java:161)
at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2624)
at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:692)
at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:426)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I use the code below:
private void loadVideo(MediaEntry mediaEntry, boolean autoPlay ) {
try {
final MediaPlayer pl = mediaView.getMediaPlayer();
if (pl != null) {
pl.stop();
pl.dispose();
pl.volumeProperty().unbind();
mediaView.setMediaPlayer(null);
}
progressBar.setVisible(true);
progressBar.bar.setProgress(ProgressBar.INDETERMINATE_PROGRESS);
playButton.setDisable(true);
playButton.setGraphic( BootstrapIcons.play_fill.glyph("glyph-blue", "glyph-24"));
final MediaPlayer mediaPlayer = new MediaPlayer( new Media(mediaEntry.getLocation()));
mediaPlayer.currentTimeProperty().addListener((o1, p1, duration) -> setProgressBarText(mediaPlayer, (long) duration.toSeconds()));
mediaPlayer.setOnReady(() ->
Platform.runLater(() -> {
playButton.setDisable( false );
if (autoPlay) {
mediaPlayer.play();
playButton.setGraphic(pauseLabel);
} else {
playButton.setGraphic(playLabel);
progressBar.bar.progressProperty().set(0d);
setProgressBarText(mediaPlayer, 0);
}
})
);
mediaView.setMediaPlayer(mediaPlayer);
mediaPlayer.volumeProperty().bind(volumeBar.progressProperty());
playButton.setDisable(false);
} catch ( Throwable ex ) {
progressBar.setVisible(false);
rx.showError(getScene(), ex.getLocalizedMessage());
}
}
private static class MediaEntry {
public final String name, url;
MediaEntry(String name, String url){
this.name = name;
this.url = url;
}
public String getLocation(){
return url;
}
@Override
public String toString() {
return name;
}
}
FREQUENCY : often
- relates to
-
JDK-8179616 Creating JFX MediaPlayer sometimes causes UNKNOWN error
-
- Open
-
-
JDK-8242076 ERROR_MEDIA_INVALID while creating a media player
-
- Closed
-