Can't play video using QtWebEngine
-
Hi @Ryan-S
@Ryan-S said in Can't play video using QtWebEngine:
The only other thing my app may have that yours might not, is using persistent cookies on the QWebEngineProfile that gets loaded with the browser.
This is interesting. Would you mind sharing how to persist cookies with a profile?
I adapted the above code to use QWebEngineProfile like this:
#include <QApplication> #include <QMainWindow> #include <QWebEngineProfile> #include <QWebEngineView> #include <QNetworkCookie> int main(int argc, char **argv) { QApplication app(argc, argv); QMainWindow* window = new QMainWindow(); QWebEngineView * view = new QWebEngineView(window); QWebEngineProfile * profile = new QWebEngineProfile(view); window->setCentralWidget(view); window->resize(1024, 768); window->show(); QWebEnginePage * page = new QWebEnginePage(profile, view); view->setPage(page); view->load(QUrl("https://www.richemont.com/")); return app.exec(); }
I still doubt this is related to proprietary codecs as QuickNanoBrowser has/does nothing special (a basic app).
@Ryan-S is there a way to avoid recompiling QtWebEngine with proprietary codecs and still get the proprietary codecs working with my app?
Recompiling everything is time consuming and require QT/system knowledge. If I can avoid this and still get the codecs working, it would be great.
Many thanks for your help.
@SGaist @Ryan-S
I tried with persistent cookies, same result. Can't load this video :-(
#include <QApplication> #include <QMainWindow> #include <QWebEngineProfile> #include <QWebEngineView> #include <QNetworkCookie> #include <QStandardPaths> int main(int argc, char **argv) { QApplication app(argc, argv); QMainWindow* window = new QMainWindow(); QWebEngineView * view = new QWebEngineView(window); QWebEngineProfile * profile = new QWebEngineProfile(view); profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache); profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); profile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); profile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); window->setCentralWidget(view); window->resize(1024, 768); window->show(); QWebEnginePage * page = new QWebEnginePage(profile, view); view->setPage(page); view->load(QUrl("https://www.richemont.com/")); return app.exec(); }
Can someone with good QtWebEngine skills help me understand why?
Many thanks -
@SGaist @Ryan-S
I tried with persistent cookies, same result. Can't load this video :-(
#include <QApplication> #include <QMainWindow> #include <QWebEngineProfile> #include <QWebEngineView> #include <QNetworkCookie> #include <QStandardPaths> int main(int argc, char **argv) { QApplication app(argc, argv); QMainWindow* window = new QMainWindow(); QWebEngineView * view = new QWebEngineView(window); QWebEngineProfile * profile = new QWebEngineProfile(view); profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache); profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); profile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); profile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); window->setCentralWidget(view); window->resize(1024, 768); window->show(); QWebEnginePage * page = new QWebEnginePage(profile, view); view->setPage(page); view->load(QUrl("https://www.richemont.com/")); return app.exec(); }
Can someone with good QtWebEngine skills help me understand why?
Many thanks -
@Zabarne
First things first: please try a variety of web pages with videos. Does the bad behaviour always apply or only to the particular video/site you mention?Hi @JonB
Most websites containing videos work as expected, but this one. This is why I asked for help.
When facing issues, I usually compare my app's behavior to QuickNanoBrowser. Till now, I was able to solve them all with my little QT knowledge. But this time, the Richemont video is perfectly working on QuickNanoBrowser but not in my app.
I followed @SGaist advice and I provided a minimalistic code to consistently reproduce this behavior on macOS, Windows and Linux (see above).
Finally, to my knowledge, QuickNanoBrowser doesn't rely on any proprietary codecs, and is still capable of loading this video.
Question: what QuickNanoBrowser does (in terms of enabled/disabled config) that my minimalistic app isn't doing?
I must be missing something.
Many thanks
-
@SGaist @Ryan-S
I tried with persistent cookies, same result. Can't load this video :-(
#include <QApplication> #include <QMainWindow> #include <QWebEngineProfile> #include <QWebEngineView> #include <QNetworkCookie> #include <QStandardPaths> int main(int argc, char **argv) { QApplication app(argc, argv); QMainWindow* window = new QMainWindow(); QWebEngineView * view = new QWebEngineView(window); QWebEngineProfile * profile = new QWebEngineProfile(view); profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache); profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); profile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); profile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); window->setCentralWidget(view); window->resize(1024, 768); window->show(); QWebEnginePage * page = new QWebEnginePage(profile, view); view->setPage(page); view->load(QUrl("https://www.richemont.com/")); return app.exec(); }
Can someone with good QtWebEngine skills help me understand why?
Many thanks -
Hi @JonB
Most websites containing videos work as expected, but this one. This is why I asked for help.
When facing issues, I usually compare my app's behavior to QuickNanoBrowser. Till now, I was able to solve them all with my little QT knowledge. But this time, the Richemont video is perfectly working on QuickNanoBrowser but not in my app.
I followed @SGaist advice and I provided a minimalistic code to consistently reproduce this behavior on macOS, Windows and Linux (see above).
Finally, to my knowledge, QuickNanoBrowser doesn't rely on any proprietary codecs, and is still capable of loading this video.
Question: what QuickNanoBrowser does (in terms of enabled/disabled config) that my minimalistic app isn't doing?
I must be missing something.
Many thanks
@Zabarne
I don't know whether this helps, but under Ubuntu 22.04, Qt 5.15, which is all I have, the video from that site runs fine in your sample code. The Qt build comes from Ubuntu viaapt-get
, and I had to goapt-get install qtwebengine5-dev
to get the QtWebEngine stuff. I don't know whether Ubuntu does a special build or does "codecs" for that. -
@Zabarne
It is a mp4 video, as I said earlier, you need to build the webengine yourself and I i'm afraid there's no escape.Trying to read this video I have an error saying my browser is not compatible and needs an update.
-
@Zabarne
I don't know, but compared to QML example do you need to (a) handle any errors (or redirections?) and (b) handle anything to do with SSL (https
)?
If you run yours, can you press a function key or something to get any diagnostics from your page, e.g. Chrome Developer mode/tools, key F12? -
Thanks @JonB. Gonna give a try.
I hope no breaking changes were introduced in Qt6.x if the video was loaded with old Qt5.15.
Keep you posted.
-
@Zabarne I tested both your code and the Quick Nano Browser example with Qt 6.6.0 on macOS and neither shows the video.