QtWebKit playing HTML5 video without installing fl

2020-07-23 04:10发布

问题:

With latest Flash player installed, and enable the Plugins, my simple example can play youtube videos

OS: windows 7

Qt: 4.7.4 (both 32 & 64bit works)

However, according to "http://www.youtube.com/html5", my example browser supports "Video tag" and "H.264", I was wondering why can't I just DISABLE the Plugins and play the video as usual? I have followed the procedure of " Watch a Video in YouTube's HTML5 Player" http://googlesystem.blogspot.com/2010/08/watch-video-in-youtubes-html5-player.html

but not work at all~

Here is my code:

int main(int argc, char *argv[])
{

  QApplication a(argc, argv);

  //QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);

  QWebView *view = new QWebView();
  view->load(QUrl("http://www.youtube.com/watch?v=cTl3U6aSd2w&html5=True"));
  view->show();
  return a.exec();
 }

Is there any code missing or I should enable anything else?

Thanks.

回答1:

I think the version you are using doesn't have html5 video support.

From the QtWebKit page:

Web Developer Features

These are some of the new features present in QtWebKit-2.2:

Support for HTML5 media (audio/video)

http://trac.webkit.org/wiki/QtWebKitFeatures22#WebDeveloperFeatures

QtWebKit 2.2 is included in Qt-4.8.



回答2:

I've written a blog post about how I've solved this issue for our project. It involves building Qt + qt-mobility, and also a bug fix in qt-mobility. See http://blog.enthought.com/open-source/fun-with-qtwebkit-html5-video/



回答3:

Just do something like that

QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);