yi.liu
yi.liu

Reputation: 1

Cannot use fullScreen when watching video in QWebEngineView

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

Upvotes: 0

Views: 605

Answers (2)

cxtan
cxtan

Reputation: 11

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;
    });

Upvotes: 1

Sz. David
Sz. David

Reputation: 111

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

Upvotes: 0

Related Questions