2 years ago
#21374

harharprogrammer
What Javafx WebEngine settings can I change to allow google to let me load the YouTube homepage?
Basically I want my javafx WebEngine to display the youtube homepage. My code to start up the browser is shown below.
browserWebView.getEngine().setJavaScriptEnabled(true);
WebConsoleListener.setDefaultListener(new WebConsoleListener() {
@Override
public void messageAdded(WebView webView, String message, int lineNumber, String sourceId) {
System.out.println("Console: [" + sourceId + ":" + lineNumber + "] " + message);
}
});
browserWebView.getEngine().load("https://www.youtube.com/");
What I end up with is a youtube homepage which looks like this unloadedYoutubeHomePage
The WebConsoleListener is a debugger which helps me find out why the youtube homepage isn't loading and it returned this.
Console: [null:0] Unrecognized Content-Security-Policy directive 'require-trusted-types-for'.
Console: [null:0] Refused to display 'https://accounts.google.com/ServiceLogin?service=youtube&uilel=3&passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26app%3Ddesktop%26hl%3Den%26next%3D%252Fsignin_passive%26feature%3Dpassive&hl=en' in a frame because it set 'X-Frame-Options' to 'DENY'.
I've been searching for solutions to this for quite a while now and it would be great if someone could help me out with my problem. Also, using embedded YouTube video URLs really isn't a solution for me as I would like to load the YouTube homepage itself, not the videos it displays. Additional info: System type: 64-bit operating system, x64-based processor Java platform: Jdk 11 Using javafx version: javafx-sdk-17.0.1
java
javafx
javafx-webengine
0 Answers
Your Answer