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

Accessing media file over network using media player results in ERROR_MEDIA_INVALID

    XMLWordPrintable

Details

    • generic
    • generic

    Description

      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


      Attachments

        Issue Links

          Activity

            People

              pnarayanaswa Praveen Narayanaswamy
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: