3 Replies Latest reply: Oct 9, 2012 2:24 PM by Sirish Vadala RSS

    Issue with media display

    Sirish Vadala
      Hello all,

      I had been trying the media example from the ensemble project (http://download.oracle.com/otndocs/products/javafx/2.0.2/samples/Ensemble/index.html#SAMPLES/Media/Advanced Media) and everything works fine.

      Now, I would like to open a media file from my local system and play it on the screen. But however I am facing issues and any hints on resolving would be highly appreciated.

      The following is the only line of code that is different from the ensemble example:
      private static final String MEDIA_URL = "file://4203_2012-04-24_(12-39-45).wmv";
      4203_2012-04-24_(12-39-45).wmv is a windows media file whose size is around 600 mb and is placed in the same source folder.

      When I run the code I do get the below exception:
      Exception in Application start method
      Exception in Application stop method
      java.lang.reflect.InvocationTargetException
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           at java.lang.reflect.Method.invoke(Method.java:601)
           at com.javafx.main.Main.launchApp(Main.java:642)
           at com.javafx.main.Main.main(Main.java:805)
      Caused by: java.lang.RuntimeException: Exception in Application start method
           at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
           at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
           at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
           at java.lang.Thread.run(Thread.java:722)
      Caused by: MediaException: MEDIA_INACCESSIBLE : 4203_2012-04-24_(12-39-45).wmv
           at javafx.scene.media.Media.<init>(Media.java:380)
           at htmleditorapp.MediaTest.init(MediaTest.java:41)
           at htmleditorapp.MediaTest.start(MediaTest.java:339)
           at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
           at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
           at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
           at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
           at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
           at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:67)
           ... 1 more
      Java Result: 1
      Any hints on resolving this would be highly appreciated.

      Thanks.
        • 1. Re: Issue with media display
          shakir.gusaroff
          Hi. For the current dir you have to use:
               final String MEDIA_URL = getClass().getResource("oow2010-2.flv").toString();
             
          The following works for me:
             private void init(Stage primaryStage) {
                   final String MEDIA_URL = getClass().getResource("oow2010-2.flv").toString();
                  Group root = new Group();
                  primaryStage.setScene(new Scene(root));
                  mediaPlayer = new MediaPlayer(new Media(MEDIA_URL));
                  mediaPlayer.setAutoPlay(true);
                  MediaControl mediaControl = new MediaControl(mediaPlayer);
                  mediaControl.setMinSize(480,280);
                  mediaControl.setPrefSize(480,280);
                  mediaControl.setMaxSize(480,280);
                  root.getChildren().add(mediaControl);
              }
          • 2. Re: Issue with media display
            Sirish Vadala
            Thanks Shakir.

            It is able to find the media file but still unable to play the content.

            Not sure what it means 'Unrecognized file signature!'. Probably it doesn't play windows media files or may be there is a file size restriction. I will try to use a small size file and test it again.
            Caused by: MediaException: MEDIA_UNSUPPORTED : Unrecognized file signature!
                 at javafx.scene.media.Media.<init>(Media.java:382)
                 at htmleditorapp.MediaTest.init(MediaTest.java:41)
                 at htmleditorapp.MediaTest.start(MediaTest.java:339)
                 at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
                 at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
                 at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
                 at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
                 at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
                 at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:67)
            Edit: And this is what I get from the javadoc:
            MEDIA_UNSUPPORTED
            public static final MediaException.Type MEDIA_UNSUPPORTED
            Indicates that this media type is not supported by this platform.
            Is there any list available indicating the media type and the size supported by the platform? BTW I am using a windows media file with extension .wmv

            Thanks.

            Edited by: Sirish Vadala on Oct 9, 2012 12:17 PM
            • 3. Re: Issue with media display
              Sirish Vadala
              Nevermind. I have found the link with details:

              http://docs.oracle.com/javafx/2/media/overview.htm

              Thanks.