qt - QtWebEngine 时是否允许使用 WebRTC 网络摄像头请求?

标签 qt qml qt5 webrtc qtwebengine

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 

但视频无法启动,因为它正在等待“允许”摄像头

enter image description here

在浏览器上你会有这个

enter image description here

有没有办法以编程方式设置 Chromium Web 引擎策略,例如VideoCaptureAllowed

最佳答案

将此添加到您的 WebEngineView 项目以从所有来源授予任何请求的功能,或选择性地将其限制为特定来源和特定功能:

    onFeaturePermissionRequested: {
        grantFeaturePermission(securityOrigin, feature, true);
    }

关于qt - QtWebEngine 时是否允许使用 WebRTC 网络摄像头请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30875545/

相关文章:

qt5 - 如何在 QT5 上安装 QT3d?

c++ - QVideoWidget 对齐时不显示任何内容

c++ - 手动执行 exe 时出现运行时错误

c++ - 在qt应用程序中实现live555的QT-C++错误

Qt - 将光标更改为沙漏并禁用光标

qt - 在 QML 中动态创建按钮

qt - QML CheckBox 设置文本大小

c++ - Qt5。 QMediaPlayer bufferStatusChanged(int) 的信号不起作用

c++ - 将焦点设置到第一个小部件

c++ - 如何从 qml 启动一个 Qthread?