Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Play a video Url in a qwidget Qt
Qt 6.11 is out! See what's new in the release blog

Play a video Url in a qwidget Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 4 Posters 3.0k Views 1 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.
  • H HW-Developer

    Hello Everyone!
    I Am a beginner in Qt learning so forgive me if this question is already asked but believe me, i searched but i didn't find anything just like what I want. So I want to play an Url video using QMediaPlayer and QVideoWidget, when i did try this code: //remplir playlist playlist->addMedia(QUrl::fromLocalFile("C:/Users/Wafae/Documents/Visual Studio 2010/Projects/maFenetre/relax-3-minutes-rainforest-animals-waterfall-and-rain-sounds.mp4")); playlist->addMedia(QUrl::fromLocalFile("C:/Users/Wafae/Documents/Visual Studio 2010/Projects/maFenetre/3-minutes-that-will-change-your-life-beautiful-nature-relaxing-inspiring-video.mp4"));

    -------------
    --------------
    playlist->addMedia(QUrl("https://youtu.be/6v2L2UGZJAM"));
        playlist->setCurrentIndex(1);
        playlist->setPlaybackMode(QMediaPlaylist::Loop);
    
        //player code
        player->setPlaylist(playlist);
        player->setVideoOutput(videoWidget);
        player->setVolume(100);
    
        //positionner videowidget
        videoWidget->setGeometry(100,100,500,400);
        videoWidget->show();
        myLayout = new QGridLayout(this);
        myLayout->addWidget(videoWidget);
           -------
         --------
    ---------
    player->play();
    

    but it skip it and come back to the first local vidéo

    Can any one help me please!

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #4

    @HW-Developer said in Play a video Url in a qwidget Qt:

    but it skip it and come back to the first local vidéo

    You mean it skips https://youtu.be/6v2L2UGZJAM ?
    That one is YouTube video, I'm not sure you can play it via Qt media.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    H 1 Reply Last reply
    4
    • jsulmJ jsulm

      @HW-Developer said in Play a video Url in a qwidget Qt:

      but it skip it and come back to the first local vidéo

      You mean it skips https://youtu.be/6v2L2UGZJAM ?
      That one is YouTube video, I'm not sure you can play it via Qt media.

      H Offline
      H Offline
      HW-Developer
      wrote on last edited by
      #5

      @jsulm it shows a black screen and play the previous video

      jsulmJ 1 Reply Last reply
      0
      • H HW-Developer

        @jsulm it shows a black screen and play the previous video

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @HW-Developer I don't think you can play a YouTube video like this. The URL should point to a video file not a web page with embedded video like YouTube.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        H 1 Reply Last reply
        1
        • jsulmJ jsulm

          @HW-Developer I don't think you can play a YouTube video like this. The URL should point to a video file not a web page with embedded video like YouTube.

          H Offline
          H Offline
          HW-Developer
          wrote on last edited by
          #7

          @jsulm so how can i play a video url using QMediaPlayer??

          jsulmJ 1 Reply Last reply
          0
          • H HW-Developer

            @jsulm so how can i play a video url using QMediaPlayer??

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #8

            @HW-Developer As you do except YouTube.
            Do you want to play YouTube video?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • H Offline
              H Offline
              HW-Developer
              wrote on last edited by
              #9

              @jsulm yes please i want to play it in my app

              jsulmJ 1 Reply Last reply
              0
              • H HW-Developer

                @jsulm yes please i want to play it in my app

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #10

                @HW-Developer I have no idea how to play a YouTube video in an app directly. One possibility would be to use QtWebEngine and load YouTube web page there.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • H Offline
                  H Offline
                  HW-Developer
                  wrote on last edited by
                  #11

                  Do you have an example how to use it ??

                  jsulmJ 1 Reply Last reply
                  0
                  • H HW-Developer

                    Do you have an example how to use it ??

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by jsulm
                    #12

                    @HW-Developer I don't, but Qt documentation does: http://doc.qt.io/qt-5/webengine-examples.html
                    But I don't know whether it can play YouTube videos as it requires codecs.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    H 1 Reply Last reply
                    3
                    • jsulmJ jsulm

                      @HW-Developer I don't, but Qt documentation does: http://doc.qt.io/qt-5/webengine-examples.html
                      But I don't know whether it can play YouTube videos as it requires codecs.

                      H Offline
                      H Offline
                      HW-Developer
                      wrote on last edited by
                      #13

                      @jsulm Really thank for your time even if we don't find how to fix it but thank you for your help

                      jsulmJ Pablo J. RoginaP 2 Replies Last reply
                      0
                      • H HW-Developer

                        @jsulm Really thank for your time even if we don't find how to fix it but thank you for your help

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #14

                        @HW-Developer No problem

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • H HW-Developer

                          @jsulm Really thank for your time even if we don't find how to fix it but thank you for your help

                          Pablo J. RoginaP Offline
                          Pablo J. RoginaP Offline
                          Pablo J. Rogina
                          wrote on last edited by
                          #15

                          @HW-Developer

                          even if we don't find how to fix it

                          Indeed, it looks like nothing to fix from Qt side. It's Youtube restricting video playing from its own site/app

                          Upvote the answer(s) that helped you solve the issue
                          Use "Topic Tools" button to mark your post as Solved
                          Add screenshots via postimage.org
                          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                          1 Reply Last reply
                          1
                          • K Offline
                            K Offline
                            k88936
                            wrote on last edited by
                            #16
                            This post is deleted!
                            1 Reply Last reply
                            0

                            • Login

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