Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. How to stream live content from YouTube using QWebEngineView
Forum Updated to NodeBB v4.3 + New Features

How to stream live content from YouTube using QWebEngineView

Scheduled Pinned Locked Moved Solved QtWebEngine
9 Posts 2 Posters 5.7k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Automata
    wrote on 27 Jul 2016, 17:37 last edited by
    #1

    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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 27 Jul 2016, 20:45 last edited by
      #2

      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

      A 1 Reply Last reply 27 Jul 2016, 21:59
      0
      • A Offline
        A Offline
        Automata
        wrote on 27 Jul 2016, 21:58 last edited by
        #3

        Thanks Chris. I did download flash player, but still not working

        1 Reply Last reply
        0
        • C Chris Kawa
          27 Jul 2016, 20:45

          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

          A Offline
          A Offline
          Automata
          wrote on 27 Jul 2016, 21:59 last edited by
          #4

          @Chris-Kawa Thanks Chris. I did download the flash player but still not working

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 27 Jul 2016, 22:25 last edited by
            #5

            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?

            A 1 Reply Last reply 28 Jul 2016, 04:33
            0
            • C Chris Kawa
              27 Jul 2016, 22:25

              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?

              A Offline
              A Offline
              Automata
              wrote on 28 Jul 2016, 04:33 last edited by
              #6

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

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Automata
                wrote on 28 Jul 2016, 04:44 last edited by
                #7

                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.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on 28 Jul 2016, 08:25 last edited by Chris Kawa
                  #8

                  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

                  A 1 Reply Last reply 28 Jul 2016, 18:16
                  0
                  • C Chris Kawa
                    28 Jul 2016, 08:25

                    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

                    A Offline
                    A Offline
                    Automata
                    wrote on 28 Jul 2016, 18:16 last edited by
                    #9

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

                    Thanks for your time

                    1 Reply Last reply
                    0

                    1/9

                    27 Jul 2016, 17:37

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved