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

Creating JFX MediaPlayer sometimes causes UNKNOWN error

    XMLWordPrintable

Details

    • generic
    • windows_10

    Description

      FULL PRODUCT VERSION :
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+166)
      Java HotSpot(TM) Server VM (build 9-ea+166, mixed mode, emulated-client)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Intel Core i7-6700
      16 GB RAM
      Intel HD Graphics 530

      A DESCRIPTION OF THE PROBLEM :
      An UNKNOWN error is thrown sometimes when creating a MediaPlayer. If you then try to play that MediaPlayer it plays nothing. I have tested this on the version listed above as well as on 1.8.0_102 and 1.8.0_111 and the the errors occurs on all of them. I have also tested this using both Eclipse and IntelliJ IDEA and again the error occurs for both. Testing on Windows 7 however never seems to throw the error, so my best guess is that the problem relates to Windows 10 in some way.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Running the attached program has always caused the error to occur for me. For the most part the error will be thrown somewhere between creating the 50th and 300th MediaPlayer, but on one occasion it took until the 1653rd MediaPlayer to be thrown.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      MediaPlayers are created and disposed of forever until a user closes the application.
      ACTUAL -
      An error is thrown at some point when creating a MediaPlayer causing the applications loop to stop.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@1e73834] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
      at javafx.media/javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
      at javafx.media/javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2618)
      at javafx.media/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:692)
      at javafx.media/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:426)

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.media.Media;
      import javafx.scene.media.MediaPlayer;
      import javafx.stage.Stage;
      import javafx.util.Duration;

      import java.io.File;

      public class MediaPlayerSample extends Application {

          private static final String VIDEO_FOLDER_PATH = "D:/assets/";

          private File[] files;
          private int nextIdx;
          private int counter = 0;
          private MediaPlayer mediaPlayer;

          public static void main(String[] args) {
              launch(args);
          }

          private void playNext() {
              counter += 1;
              if (files == null || files.length == 0) {
                  return;
              }

              Media media = new Media(files[nextIdx++].toURI().toString());
              System.out.println(counter + " " + media.getSource());

              if (nextIdx >= files.length) {
                  nextIdx = 0;
              }

              if (mediaPlayer != null) {
                  mediaPlayer.stop();
                  mediaPlayer.dispose();
              }

              mediaPlayer = new MediaPlayer(media);
              mediaPlayer.setOnError(() -> {
                  mediaPlayer.getError().printStackTrace();
              });
              mediaPlayer.setStopTime(new Duration(100));
              mediaPlayer.setOnEndOfMedia(() -> playNext());
              mediaPlayer.play();
          }

          @Override
          public void start(Stage primaryStage) throws Exception {
              File videoFolder = new File(VIDEO_FOLDER_PATH);
              files = videoFolder.listFiles();
              playNext();
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found.

      Attachments

        Issue Links

          Activity

            People

              almatvee Alexander Matveev
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: