gpt4 book ai didi

java - 为什么 JavaFX WebView 不允许视频全屏模式

转载 作者:行者123 更新时间:2023-11-29 08:35:39 56 4
gpt4 key购买 nike

Description

作为示例,我给出了 www.youtube.com,它允许您观看任何类型的视频。以下是来自 Oracle Tutorial 的最低代码使用 JavaFX WebView 显示网站。

问题是:

  • 1) 不允许全屏播放任何视频。

  • 2) 即使视频支持全高清也无法播放。

Question

为什么会这样?我已经尝试使用最新的 Java 8 Update 131Java 9 update 171

Code:

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewSample extends Application {

private Scene scene;

@Override
public void start(Stage stage) {

// create scene
stage.setTitle("Web View");
scene = new Scene(new Browser(),Color.BLACK);
stage.setScene(scene);
stage.show();
}

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

class Browser extends BorderPane {

final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();

public Browser() {
//add components
setCenter(browser);

// load the home page
webEngine.load("https://www.youtube.com");
}

// JavaScript interface object
public class JavaApp {

public void exit() {
Platform.exit();
}
}

}

enter image description here

最佳答案

  • 不能全高清

    Youtube 仅支持某些版本的 Chrome/IE/Safari/Firefox 上的高质量视频。 (我用 JDK8 编译了你的程序,它最高支持 720p。)你可以在点击“质量”->“缺少选项?”时找到以下详细信息

Below are some browser and operating system combinations that support YouTube's high-quality video formats:

Google Chrome (all operating systems)

Internet Explorer or Edge on Windows 8.1 or newer

Safari on Mac OS X 10.10 or newer

Firefox on Windows 7 or newer and on Mac OS X 10.10 or newer

关于java - 为什么 JavaFX WebView 不允许视频全屏模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44251826/

56 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com