1

My question is if or if not Youtube-Livestreams can be played using JDK 8u102. Using the WebView, it is easily possible to play Youtube-Videos (VoDs). Example:

package application;

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) {
        try {
            WebView embeddedWV = new WebView();
            embeddedWV.getEngine().load(
            "https://www.youtube.com/embed/oyA8odjCzZ4"
            );
            embeddedWV.setPrefSize(640, 400);
            Scene scene = new Scene(embeddedWV);
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

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

But that approach does not work for Live-Streams such as https://youtu.be/opHkchLbYR4 . An Error states that WebM VP8, Media Source Extensions, MSE & H.264 and MSE & WebM VP9 are not supported by my "browser"/application. An approach, that worked (but had terrible performance) was described here, but that is an approach for Swing, not JavaFX8. It's still a proof of concept which shows that it is possible to play the Streams inside Java-Applications. I also read this, but it is 1. for Android/IOS and 2. only refers to the Youtube-Life API, which does not actually answer the question and seems like a little overkill for what i try to accomplish.

My question is: Is it somehow possible to play the Livestreams broadcasted by Youtube insinde an JavaFX 8 application? If it's not natively possible, are there external libraries to accomplish such goal?

Community
  • 1
  • 1
SilverMonkey
  • 1,003
  • 7
  • 16

1 Answers1

0
public void start(Stage primaryStage) {
        StackPane root = new StackPane();
        Scene scene = new Scene(root, 640, 400);
        primaryStage.setScene(scene);
        WebView embeddedWV = new WebView();
        embeddedWV.getEngine().load(
       "https://www.youtube.com/embed/oyA8odjCzZ4"
            );
            embeddedWV.setPrefSize(640, 400);
            root.getChildren().add(embeddedWV);

            primaryStage.setScene(scene);
            primaryStage.show();
    }