我是 Qt 学习的初学者,如果已经问过这个问题,请原谅我,但相信我,我搜索过,但没有找到任何我想要的东西。所以我想用QMediaPlayer
and播放一个 Url 视频QVideoWidget
,当我尝试这段代码时:
//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();
但它跳过它并回到第一个本地视频
任何人都可以帮助我吗?