0

Using PyQt5 QWebEngineView, I cannot use fullScreen when watching video:

import sys 
from PyQt5 import QtWidgets, QtGui, QtCore 
from PyQt5.QtWebEngineWidgets import * 

app=QtWidgets.QApplication(sys.argv) 
w=QWebEngineView() 
w.settings().setAttribute(QWebEngineSettings.PluginsEnabled, True)
w.settings().setAttribute(QWebEngineSettings.JavascriptEnabl‌​ed, True) 
w.settings().setAttribute(QWebEngineSettings.FullScreenSuppo‌​rtEnabled, True)
w.page().fullScreenRequested.connect(QWebEngineFullScreenReq‌​uest.accept) 
w.load(QtCore.QUrl('56.com/w94/play_album-aid-14364505_vid-M‌​TQ3NDUxMjY3.html'))

w.showMaximized() 
app.exec_()

enter image description here

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
yi.liu
  • 1
  • `56.com/w94/play_album-aid-14364505_vid-M‌​TQ3NDUxMjY3.html` or `http://www.56.com/w94/play_album-aid-14364505_vid-M‌​TQ3NDUxMjY3.html` – eyllanesc Nov 16 '17 at 12:51
  • When you access the link directly it tells me that the place does not exist and redirects me to the main page. – eyllanesc Nov 16 '17 at 12:54

2 Answers2

1

you can reference bellow code:

m_webView->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);

connect(m_webView->page(), &QWebEnginePage::fullScreenRequested, this, [this] 
(QWebEngineFullScreenRequest fullScreenRequest) {
        fullScreenRequest.accept();
        qDebug()<<"UI: fullScreenRequested: "<<fullScreenRequest.toggleOn()<<endl;
    });
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
cxtan
  • 11
  • 2
0

QWebEnginePage::fullScreenRequested signal has an argument named "request" and it has a function named "accept()". So you have to call

request.accept()

but your code uses the type name (QWebEngineFullScreenRequest) and doesn't refer to this exact object.

https://doc.qt.io/qt-5/qwebenginepage.html#fullScreenRequested

Sz. David
  • 111
  • 1
  • 6