<bdo id='nHdkf'></bdo><ul id='nHdkf'></ul>

  1. <i id='nHdkf'><tr id='nHdkf'><dt id='nHdkf'><q id='nHdkf'><span id='nHdkf'><b id='nHdkf'><form id='nHdkf'><ins id='nHdkf'></ins><ul id='nHdkf'></ul><sub id='nHdkf'></sub></form><legend id='nHdkf'></legend><bdo id='nHdkf'><pre id='nHdkf'><center id='nHdkf'></center></pre></bdo></b><th id='nHdkf'></th></span></q></dt></tr></i><div id='nHdkf'><tfoot id='nHdkf'></tfoot><dl id='nHdkf'><fieldset id='nHdkf'></fieldset></dl></div>

  2. <tfoot id='nHdkf'></tfoot>
    1. <legend id='nHdkf'><style id='nHdkf'><dir id='nHdkf'><q id='nHdkf'></q></dir></style></legend>

    2. <small id='nHdkf'></small><noframes id='nHdkf'>

      授予对 Cam &amp; 的访问权限将 Python 用于 PyQt

      时间:2023-08-05
      <i id='Rzoe7'><tr id='Rzoe7'><dt id='Rzoe7'><q id='Rzoe7'><span id='Rzoe7'><b id='Rzoe7'><form id='Rzoe7'><ins id='Rzoe7'></ins><ul id='Rzoe7'></ul><sub id='Rzoe7'></sub></form><legend id='Rzoe7'></legend><bdo id='Rzoe7'><pre id='Rzoe7'><center id='Rzoe7'></center></pre></bdo></b><th id='Rzoe7'></th></span></q></dt></tr></i><div id='Rzoe7'><tfoot id='Rzoe7'></tfoot><dl id='Rzoe7'><fieldset id='Rzoe7'></fieldset></dl></div>
        <tbody id='Rzoe7'></tbody>

      <small id='Rzoe7'></small><noframes id='Rzoe7'>

      • <bdo id='Rzoe7'></bdo><ul id='Rzoe7'></ul>

                <tfoot id='Rzoe7'></tfoot>
                <legend id='Rzoe7'><style id='Rzoe7'><dir id='Rzoe7'><q id='Rzoe7'></q></dir></style></legend>

              1. 本文介绍了授予对 Cam &amp; 的访问权限将 Python 用于 PyQt WebEngine 的麦克风的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在构建一个从 Python 调用的简单 Web 应用程序.我正在使用下面的代码.以编程方式授予对 Cam & 的访问权限的最简单方法是什么?加载此页面时的麦克风?我只在网上找到了 C++ 示例,在 Python 代码中找不到这样做的方法.

                I am building a simple web app called from Python. I am using the below code. What is the easiest way to programatically grant access to the Cam & Mic when this page is loaded? I have only found C++ examples on the web and cannot find a way to do this within Python code.

                from PyQt5.QtWidgets import QApplication
                from  PyQt5.QtWebEngineWidgets import QWebEngineView
                from PyQt5.QtCore import QUrl
                
                app = QApplication([])
                
                view = QWebEngineView()
                view.load(QUrl("https://test.webrtc.org/"))
                view.show()
                app.exec_()
                

                推荐答案

                要授予权限,您必须使用 QWebEnginePage 的 ="noreferrer">setFeaturePermission 方法,但必须当视图发出 featurePermissionRequested 时要求您这样做信号,这将指示 url 和 feature.p>

                To give permission you must use the setFeaturePermission method of QWebEnginePage, but you must do it when the view asks you to do so when it emits the featurePermissionRequested signal, this will indicate the url and the feature.

                from PyQt5.QtWidgets import QApplication
                from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
                from PyQt5.QtCore import QUrl
                
                class WebEnginePage(QWebEnginePage):
                    def __init__(self, *args, **kwargs):
                        QWebEnginePage.__init__(self, *args, **kwargs)
                        self.featurePermissionRequested.connect(self.onFeaturePermissionRequested)
                
                    def onFeaturePermissionRequested(self, url, feature):
                        if feature in (QWebEnginePage.MediaAudioCapture, 
                            QWebEnginePage.MediaVideoCapture, 
                            QWebEnginePage.MediaAudioVideoCapture):
                            self.setFeaturePermission(url, feature, QWebEnginePage.PermissionGrantedByUser)
                        else:
                            self.setFeaturePermission(url, feature, QWebEnginePage.PermissionDeniedByUser)
                
                app = QApplication([])
                
                view = QWebEngineView()
                page = WebEnginePage()
                view.setPage(page)
                view.load(QUrl("https://test.webrtc.org/"))
                view.show()
                app.exec_()
                

                这篇关于授予对 Cam &amp; 的访问权限将 Python 用于 PyQt WebEngine 的麦克风的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使用 target=“_blank"打开超链接在 PyQtWeb 下一篇:PyQt5 和 Django:如何使用 HTTP 请求(Multipart-form)上传

                相关文章

                最新文章

              2. <small id='WQjqW'></small><noframes id='WQjqW'>

              3. <i id='WQjqW'><tr id='WQjqW'><dt id='WQjqW'><q id='WQjqW'><span id='WQjqW'><b id='WQjqW'><form id='WQjqW'><ins id='WQjqW'></ins><ul id='WQjqW'></ul><sub id='WQjqW'></sub></form><legend id='WQjqW'></legend><bdo id='WQjqW'><pre id='WQjqW'><center id='WQjqW'></center></pre></bdo></b><th id='WQjqW'></th></span></q></dt></tr></i><div id='WQjqW'><tfoot id='WQjqW'></tfoot><dl id='WQjqW'><fieldset id='WQjqW'></fieldset></dl></div>
                <tfoot id='WQjqW'></tfoot>
                  <bdo id='WQjqW'></bdo><ul id='WQjqW'></ul>

                    <legend id='WQjqW'><style id='WQjqW'><dir id='WQjqW'><q id='WQjqW'></q></dir></style></legend>