2

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&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
             """
web.setHtml(htmlString, QUrl(baseUrl))
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
joke4me
  • 812
  • 1
  • 10
  • 29

1 Answers1

2

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&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
             """
    web.setHtml(htmlString, QUrl(baseUrl))

    web.show()
    sys.exit(app.exec_())

Screenshot:

enter image description here

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • btw, i'm seeing this warnings in PyCharm console, any idea what this means? "[20068:5672:1031/203943.715:ERROR:gl_context_wgl.cc(78)] Could not share GL contexts." – joke4me Oct 31 '17 at 15:14
  • 1
    Those are Chromium warnings, the backend that Qt uses for QWebEngineView, is telling you that some things are not supported, but they are not errors. These are the same messages generated by google-chrome, mozilla, etc. if you run it from the console. – eyllanesc Oct 31 '17 at 15:17
  • Thanks much again! – joke4me Oct 31 '17 at 15:23