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

WebView error playing Kaltura videos

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8, openjfx13
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Found in openjdk11/openjfx11, verified still a problem with openjdk13/openjfx13. Both Windows 10 and Mac 10.13.


      A DESCRIPTION OF THE PROBLEM :
      Kaltura has a javascript video player that I am trying to get work within WebView. See http://player.kaltura.com/docs/kwidget. When loading from WebView, clicking play button doesn't work and console shows:

      Oct 01, 2019 2:03:58 PM com.sun.javafx.webkit.prism.WCMediaPlayerImpl$CreateThread run
      WARNING: CreateThread ERROR: com.sun.media.jfxmedia.MediaException: Unrecognized file signature!
      Oct 01, 2019 2:03:58 PM com.sun.javafx.webkit.prism.WCMediaPlayerImpl onError
      WARNING: onError, errCode=0, msg=Unrecognized file signature!


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      To repro, use the following test program that accesses the Kaltura player api test pages, and click the play button in the video.

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class Main extends Application {

          @Override
          public void start(Stage primaryStage) throws Exception{
              WebView webView = new WebView();
              webView.getEngine().load("http://player.kaltura.com/docs/kwidget");

              primaryStage.setTitle("WebView");
              primaryStage.setScene(new Scene(webView));
              primaryStage.show();
          }


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


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Video should play
      ACTUAL -
      Oct 01, 2019 2:03:58 PM com.sun.javafx.webkit.prism.WCMediaPlayerImpl$CreateThread run
      WARNING: CreateThread ERROR: com.sun.media.jfxmedia.MediaException: Unrecognized file signature!
      Oct 01, 2019 2:03:58 PM com.sun.javafx.webkit.prism.WCMediaPlayerImpl onError
      WARNING: onError, errCode=0, msg=Unrecognized file signature!


      CUSTOMER SUBMITTED WORKAROUND :
      Root cause is that `com.sun.media.jfxmedia.locator.Locator` is trying to get the media type from a URL by looking at it's file extension, but it's using the whole URI string instead of URI.getPath(). This won't work if the URI contains query parameters, which is what Kaltura seems to be passing back.

      Fix is to change 3 places in `com.sun.media.jfxmedia.locator.Locator` to use just the URI.getPath() value:

      ```
      diff --git a/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/Locator.java b/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/Locator.java
      index 447ec6accf..b92957bde7 100644
      --- a/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/Locator.java
      +++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/Locator.java
      @@ -437,7 +437,7 @@ public class Locator {
                                   } else {
                                       if (contentType == null || !MediaManager.canPlayContentType(contentType)) {
                                           // Try content based on file name.
      - contentType = MediaUtils.filenameToContentType(uriString);
      + contentType = MediaUtils.filenameToContentType(uri.getPath());

                                           if (Locator.DEFAULT_CONTENT_TYPE.equals(contentType)) {
                                               // Try content based on file signature.
      @@ -608,7 +608,7 @@ public class Locator {
               ConnectionHolder holder;
               if ("file".equals(scheme)) {
                   holder = ConnectionHolder.createFileConnectionHolder(uri);
      - } else if (uri.toString().endsWith(".m3u8") || uri.toString().endsWith(".m3u")) {
      + } else if (uri.getPath().endsWith(".m3u8") || uri.getPath().endsWith(".m3u")) {
                   holder = ConnectionHolder.createHLSConnectionHolder(uri);
               } else {
                   synchronized (propertyLock) {
      ```

      I have verified this works as a patch.


      FREQUENCY : always


        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated: