QtWebEngine 时如何允许使用 WebRTC 网络摄像头请求(是否使用 QML 插件时)?webengine.qml
import QtQuick 2.1
import QtQuick.Controls 1.1
import QtWebEngine 1.0
ApplicationWindow {
width: 800
height: 600
color: "lightgray"
visible: true
WebEngineView {
id: webview
url: "https://opentokrtc.com/test"
anchors.fill: parent
}
}
在我的 Mac Yosemite 上,运行以下命令:
/usr/local/Cellar/qt5/5.4.0/bin/qmlscene webengine.qml
但视频无法启动,因为它正在等待“允许”摄像头
在浏览器上你会有这个
有没有办法以编程方式设置 Chromium Web 引擎策略,例如VideoCaptureAllowed
最佳答案
将此添加到您的 WebEngineView 项目以从所有来源授予任何请求的功能,或选择性地将其限制为特定来源和特定功能:
onFeaturePermissionRequested: {
grantFeaturePermission(securityOrigin, feature, true);
}
关于qt - QtWebEngine 时是否允许使用 WebRTC 网络摄像头请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30875545/