Issue
I'm trying to embed a youtube video in a QWebEngineView, the video loads fine but the fullscreen button is disabled with this message "Fullscreen is unavailable" even thought the embed code does have "allowfullscreen"
Code snippet:
web = QWebEngineView()
htmlString = """
<iframe width="560" height="315" src="https://www.youtube.com/embed/L0MK7qz13bU?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
"""
web.setHtml(htmlString, QUrl(baseUrl))
Solution
To enable the full screen it is necessary to enable the FullScreenSupportEnabled attribute and accept the fullScreenRequested order of the page.
if __name__ == '__main__':
app = QApplication(sys.argv)
web = QWebEngineView()
web.settings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True)
web.page().fullScreenRequested.connect(lambda request: request.accept())
baseUrl = "local"
htmlString = """
<iframe width="560" height="315" src="https://www.youtube.com/embed/L0MK7qz13bU?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
"""
web.setHtml(htmlString, QUrl(baseUrl))
web.show()
sys.exit(app.exec_())
Screenshot:
Answered By - eyllanesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.