Unsolved Play a video Url in a qwidget Qt
-
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!
-
@HW-Developer said in Play a video Url in a qwidget Qt:
playlist->setCurrentIndex(1);
Shouldn't it be
playlist->setCurrentIndex(0);
?
-
Even if i chenge it to:
playlist->setCurrentIndex(0);
it changes nothing
-
@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. -
@jsulm it shows a black screen and play the previous video
-
@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.
-
@jsulm so how can i play a video url using QMediaPlayer??
-
@HW-Developer As you do except YouTube.
Do you want to play YouTube video? -
@jsulm yes please i want to play it in my app
-
@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.
-
Do you have an example how to use it ??
-
@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. -
@jsulm Really thank for your time even if we don't find how to fix it but thank you for your help
-
@HW-Developer No problem
-
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