Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to stream live content from YouTube using QWebEngineView
Hello all. Please I'm trying to stream live content from youtube using QWebEngineView's load method.
I'm currently passing the live media's url as an argument to load(), as follows:
QWebEngineView *webEngineView = new QWebEngineView; webEngineView->load(QUrl("https://someURL"));
I get a blank screen with the following piece of text
"Your browser does not currently recognize any of the video formats available"
In Btw, I really would love in addition to getting live content displayed through the QWebEngineView, I also would want to show only the video frame from YouTube.
I'm using Qt 5.7 MSVC2015, on a windows 7 machine.
Thanks in advance
You can use flash based player for that. The downside is that you need to install flash player separately:
- download flash player from here. Make sure you select the "Opera and Chromium based applications – PPAPI" version. No other will work with QWebEngineView.
- enable plugins support in web engine view:
webEngineView ->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
- Use the video link in either the Embedded AS3 player or Chromeless AS3 player format:
webEngineView->load(QStringLiteral("http://www.youtube.com/apiplayer?video_id=%1&version=3").arg(video_id)); //or webEngineView->load(QStringLiteral("http://www.youtube.com/v/%1&version=3").arg(video_id));
video_idis the last part in the usual youtube links: http ://youtu.be/video_id
Thanks Chris. I did download flash player, but still not working
@Chris-Kawa Thanks Chris. I did download the flash player but still not working
What does "not working" mean?
If the page is blank then you either did not enable plugins or installed the wrong player.
If you still get that "Your browser..." message then you're using the wrong url format because that message shows up in HTML5 player, not the flash one.
Can you post an example url that "doesn't work"? Can you post a link to the exact version of the player you installed?
@Chris-Kawa Here is the link of the flash player I downloaded
which installed here:
And here is the code
QWebEngineView *webEngineView = new QWebEngineView; webEngineView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); webEngineView->load(QUrl("https://www.youtube.com/embed/l-EJCJn3QqM"));
Note, that this link was got from a live stream (which is what I want to play. I don't have issues with playing a normal youtube video). I got this link by right clicking on the live video from Chrome browser and copying the embed code, which was this
<iframe width="854" height="480" src="https://www.youtube.com/embed/l-EJCJn3QqM" frameborder="0" allowfullscreen></iframe>
From which I extracted the video's link to show only the video.
I did not see how to format my url as your examples.
Wow! So sorry for that post. It finally worked!
I remember after installing that flash player, it asked me to restart my browser. So, I decided to restart Qt Creator now.
After running the code. It still displayed that message, the screen flickered, and the video started playing.
Thank you so much Chris.
That's a HTML5 link. It works because it tests all available codecs and then falls back to flash when it can't find any.
If you want to skip that testing (that will fail anyway) you should use one of the links I mentioned:
Your code works seamlessly for normal YouTube videos. Live video streams still have the flicker effect.
Thanks for your time