0

我正在使用 WebEngineView QML 类型来呈现本地托管的网页,该网页使用 Qt 5.15.1 上的 WebRTC HTML 媒体音频捕获功能(在 WebEngineView 可用的功能中列出。

该网页使用 nginx 服务器在本地托管,并且在其他浏览器访问时可以完美运行。

使用 WebEngineView 访问它时,麦克风没有捕获很可能是由于未授予这样做的权限。

使用 WebEngineView 打开网页时,控制台中不会出现任何类型的错误,它只是没有从系统输入源捕获音频。

有谁知道如何通过 Qt WebEngineView 或其他方式正确地授予此特定功能权限?

这是我的代码的样子。

main.qml

import QtQuick 2.15
import QtQuick.Window 2.15

import QtWebEngine 1.10

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")
    WebEngineView {
        id: view
        anchors.fill: parent
        url: "http://127.0.0.1/audio.html"
        Component.onCompleted: {


         /* heres my attempt to grant permission 
          to use the microphone, which did not 
          seem to have any affect */

            view.grantFeaturePermission("http://127.0.0.1",
                                    MediaAudioCapture, true)                                        
        }
    }
}

有谁知道如何通过 Qt WebEngineView 或其他方式正确地授予此特定功能权限?

** 编辑 **

audio.html(相关代码)

<!DOCTYPE html>
<head></head><body><div id="results"></div><script>
window.rc = new webkitSpeechRecognition()
    rc.continuous = true;
    
    rc.onresult = function(result) {
    document.querySelector("#results").innerHTML = result.results[0][0].transcript;
    }
rc.start();


        
</script></body></html>
4

0 回答 0