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

AAC over http streaming not working in MediaPlayer

    XMLWordPrintable

Details

    • x86_64
    • windows_10

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10
      openjdk version "17.0.4" 2022-07-19
      OpenJDK Runtime Environment Temurin-17.0.4+8 (build 17.0.4+8)
      OpenJDK 64-Bit Server VM Temurin-17.0.4+8 (build 17.0.4+8, mixed mode, sharing)
      OpenJFX: 18.0.2-R29

      A DESCRIPTION OF THE PROBLEM :
      Using MediaPlayer to play an AAC Audio Stream over HTTP fails with following Exception:

      MediaException: MEDIA_UNSUPPORTED : Unrecognized file signature!
      at javafx.scene.media.Media._setError(Media.java:513)
      at javafx.scene.media.Media$InitLocator.run(Media.java:566)
      at java.base/java.lang.Thread.run(Thread.java:833)

      Here two URLs which don't work:
      <link1>
      <link2>

      The error occurs in com.sun.media.jfxmediaimpl.MediaUtils, mehod: fileSignatureToContentType.

      I noticed the bytes which are used to identify the stream type are always different, so I assume the content available at the URL does not start with a header which allows the client to identify the stream type. I think the content starts with the audio data directly.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a MediaPlayer, with a Media instance set to a HTTP Url like this:

      Media media = new Media("<Link>")

      And then call .play() on the media player.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The audio content is played.
      ACTUAL -
      An Exception:

      MediaException: MEDIA_UNSUPPORTED : Unrecognized file signature!
      at javafx.scene.media.Media._setError(Media.java:513)
      at javafx.scene.media.Media$InitLocator.run(Media.java:566)
      at java.base/java.lang.Thread.run(Thread.java:833)



      ---------- BEGIN SOURCE ----------
      package com.example.fxdemo;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.VBox;
      import javafx.scene.media.Media;
      import javafx.scene.media.MediaPlayer;
      import javafx.stage.Stage;

      import java.io.IOException;

      public class FXMediaPlayerDemo extends Application {

      @Override
      public void start(Stage stage) throws IOException {

      Media media = new Media("<link>");
      media.setOnError( () -> {
      media.getError().printStackTrace();
      } );
      MediaPlayer mediaPlayer = new MediaPlayer(media);
      VBox container = new VBox();
      Button button = new Button();
      button.setText( "Play" );
      button.setOnAction( (event) ->
      mediaPlayer.play()
      );

      container.getChildren().add( button );

      Scene scene = new Scene( container );
      stage.setScene( scene );
      stage.show();
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      There is none.

      FREQUENCY : always


      Attachments

        1. FXMediaPlayerDemo.java
          0.9 kB
          Praveen Narayanaswamy

        Activity

          People

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

            Dates

              Created:
              Updated: