JDK-8094657 : Web View cannot play anything on youtube
  • Type: Bug
  • Component: javafx
  • Sub-Component: media
  • Affected Version: 8u45
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2015-05-06
  • Updated: 2015-06-12
  • Resolved: 2015-05-06
Related Reports
Duplicate :  
Description
The code below opens a web view with youtube. None of the videos will play. It says "An error occurred, please try again later."

This is the third most popular website on the planet so it's a bit bad.

I know there have been problems with https and media. I tried to embed youtube on my own site with http in the iframe src. But in developer tools I see that the media is still fetched with the https scheme. I suspect that might be something new.

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewer extends Application
{
   @Override
   public void start(Stage stage)
   {
      stage.setTitle("Youtube");
      stage.setWidth(700);
      stage.setHeight(500);
      Scene scene = new Scene(new Group());
      VBox root = new VBox();
      final WebView browser = new WebView();
      final WebEngine webEngine = browser.getEngine();
      webEngine.load("http://youtube.com");
      root.getChildren().addAll(browser);
      scene.setRoot(root);
      stage.setScene(scene);
      stage.show();
   }

   public static void main(String[] args)
   {
      launch(args);
   }
}
Comments
Yeah, that was pretty funny we both made the same comment at the same time.
06-05-2015

Thanks, Kevin. Concurrency in action :)
06-05-2015

This is not a bug, but is a known limitation of the JavaFX media player, which does not support playing media files over https. Closing as a duplicate of RT-28420
06-05-2015

Unfortunately, FX Media component (used to play back media content in WebView) doesn't support HTTPS. By default, youtube.com redirects requests to https:// protocol (however this may vary depending on your connection, your proxy settings etc.) That's the problem. More details is here: RT-28420.
06-05-2015