I'm trying to play a Youtube video in a JavaFX WebView. Like other people, I keep getting the "An error occurred, please try again later." error. (Also Soundcloud doesn't work either, that can use HTML 5 only)
My code is simply:
public static void main(String[] args){
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle(TITLE);
WebView wbv = new WebView();
wbv.getEngine().load("http://www.youtube.com/");
wbv.setPrefSize(854, 480);
primaryStage.setScene(new Scene(wbv));
primaryStage.show();
}
I have already tried:
- Using the embed link e.g. https://www.youtube.com/embed/puAuDt6aNsw
- Using the regular youtube link
- Wrapping the embed link in an iframe
- Installing DivX codecs (and the software)
If I try a different website with an HTML 5 player (http://www.videojs.com), it works.
So I'm guessing it must be something to do with Youtube and Soundcloud.
Is there anyway I can make this work? Thanks