Can't play video using QtWebEngine
-
I have a custom Qt app that uses a QtWebEngine browser and it can successfully playback the video at the top of the page.
My QtWebEngine was compiled with proprietary codecs and if I had to guess, this is almost certainly the issue. I'm not knowledgeable enough to know which codecs are included when compiling with proprietary codecs or why QuickNanoBrowser would work...does QuickNanoBrowser perhaps come with an open source codec like OpenH264? According to VLC, the video is using a basic h264 codec.
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. Perhaps the site requires something on the cookie-side, but that seems less likely than the codec(s).
-
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.
-
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
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?