1
votes

In my program, I have a QWebView that displays a YouTube video. The code I use has worked perfectly fine for me in the past, however one day I noticed it wasn't working anymore. I have Flash installed, and other websites (google) load just fine. Here is my code:

QNetworkProxyFactory::setUseSystemConfiguration(true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
ui->webView->load(QUrl("https://www.youtube.com/embed/abakM9O_Bos"));
ui->webView->setEnabled(true);

Can anyone explain why this used to work for me in the past but now it isn't? I tried http and https with no luck.

1

1 Answers

0
votes

Things I would look into:

  • Do other video sites work? (Vimeo, for example)
  • Are you viewing the YouTube videos through flash, or HTML5?
  • Can you confirm that your web view is loading your flash plugin by going to one of the flash test pages?
  • Does it work with the Qt web browser example project?

If none of those point you in the right direction, I would definitely consider going to QtWebEngine. QtWebEngine is built using the Chromium platform, and is able to handle complex webpages really well. I've also noticed that QtWebEngine is significantly faster and more stable that the old QtWebKit based widgets. Plus, QtWebKit is no longer going to be updated, so if you're building a new application, it might be better to start with the newer system. Hopefully this helps!

Update Just to summarize what has been stated in the comments:

  • This is likely an HTML5 issue, where QtWebKit doesn't have the H.264 codec built in.
  • As a result, you need to ship your application with the codecs you need. Specifically, I'd suggest ffmpeg (ffmpegsumo.dll), as this is what Chrome uses.