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


  • Moderators

    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));
    

    where video_id is 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


  • Moderators

    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

    https://fpdownload.macromedia.com/get/flashplayer/current/licensing/win/install_flash_player_22_ppapi.exe

    which installed here:
    C:\Windows\System32\Macromed\Flash

    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.

    Thank you.



  • 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.


  • Moderators

    https ://www.youtube.com/embed/l-EJCJn3QqM

    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:

    https ://www.youtube.com/apiplayer?video_id=l-EJCJn3QqM&version=3
    or
    https ://www.youtube.com/v/l-EJCJn3QqM&version=3



  • Your code works seamlessly for normal YouTube videos. Live video streams still have the flicker effect.

    Thanks for your time


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.