qmediaplayer

Loading video using QMediaPlayer and UNC paths

孤者浪人 提交于 2019-12-11 11:51:19
问题 I'm trying to load a video from a network using UNC paths thanks to Qt 5.5 QMediaPlayer. The code snippet is the following one: projectDirectory = QFileDialog::getExistingDirectory (this, tr ("Choose project folder (sensor + video data"), QDir::homePath(), QFileDialog::ShowDirsOnly); QDir dir(projectDirectory); QStringList test = dir.entryList(); qDebug () << projectDirectory << "contains:" << endl << test; mediaPlayer.setMedia(QUrl::fromLocalFile(projectDirectory+"/video.mov")); The code

QVideoWidget: Video is cut off

孤街醉人 提交于 2019-12-10 11:09:54
问题 I want to play a video in a Qt Application. This is my code so far: #include <QApplication> #include <QWidget> #include <QMediaPlayer> #include <QVideoWidget> #include <QUrl> #include <iostream> using namespace std; const int WIDTH = 1280; const int HEIGHT = 720; int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; window.resize(WIDTH, HEIGHT); window.setWindowTitle("Video Test"); window.show(); QMediaPlayer *player = new QMediaPlayer(); player->setMedia(QUrl:

QVideoWidget: Video is cut off

白昼怎懂夜的黑 提交于 2019-12-06 04:34:17
I want to play a video in a Qt Application. This is my code so far: #include <QApplication> #include <QWidget> #include <QMediaPlayer> #include <QVideoWidget> #include <QUrl> #include <iostream> using namespace std; const int WIDTH = 1280; const int HEIGHT = 720; int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; window.resize(WIDTH, HEIGHT); window.setWindowTitle("Video Test"); window.show(); QMediaPlayer *player = new QMediaPlayer(); player->setMedia(QUrl::fromLocalFile("/Path/To/Video.mp4")); QVideoWidget *videoWidget = new QVideoWidget(&window); player-

Using a resource file in QMediaPlayer

好久不见. 提交于 2019-12-05 17:03:40
How do I load a .mp3 file to use in a QMediaPlayer from a .qrc resource file? This is what I have so far QMediaPlayer *player = new QMediaPlayer; player->setMedia(QUrl::fromLocalFile(":/audio/theme.mp3")); player->play(); resources.qrc: <RCC> <qresource prefix="/audio"> <file>theme.mp3</file> </qresource> </RCC> theme.mp3 is located in the project directory. Use m_player->setMedia(QUrl("qrc:/audio/theme.mp3")); If you are using Qt Creator, you can copy this url to clipboard by pressing right button on the audio file in the side bar and choosing Copy url "..." . 来源: https://stackoverflow.com

Is there a way in Qt to force QMediaPlayer to buffer a file without playing it?

孤者浪人 提交于 2019-12-04 20:27:14
问题 When you load a file into a QMediaPlayer instance, it does not automatically buffer the file. The MediaStatus remains NoMedia until you play the file using play() , only after which it will end up as BufferedMedia . I can't find any way in the documentation to force the player to buffer the file without playing it - is there any way to do this? Right now I'm planning on muting it, playing the file, then stopping it again and unmuting it, but it makes me feel dirty. Surely there is a better

QMediaPlayer doesn't produce audio

吃可爱长大的小学妹 提交于 2019-12-02 10:22:29
I am starting out in C++ and I am trying to play an mp3 file with Qt. I wrote this code but it is not working for some reason. I have searched the internet but was unable to find something that would help. Here's my code: #include <iostream> #include <QMediaPlayer> #include <QMediaPlaylist> #include <QFileInfo> #include <QUrl> int main() { QMediaPlaylist *list = new QMediaPlaylist; list->addMedia(QUrl::fromLocalFile(QFileInfo("Filename.mp3").absoluteFilePath())); QMediaPlayer *music; music = new QMediaPlayer(); music->setPlaylist(list); music->play(); return 0; } There is no music playing and

play background music in a loop Qt

时光总嘲笑我的痴心妄想 提交于 2019-12-01 01:40:01
问题 I want to play background music continually in a loop until the game ends. in the header file: QMediaPlayer * music = new QMediaPlayer(); in the cpp file: startGame(){ music->setMedia(QUrl("qrc:/sounds/backgroundmusic.mp3")); music->play(); } stopGame(){ music->stop(); } Right now my music plays thru to the end but does not restart. How can I get it to loop over again again? Is there a QMediaPlayer member I can use, or should I run it in a while loop, or what? 回答1: Sounds like what you want

QMediaPlayer - playing youtube music

 ̄綄美尐妖づ 提交于 2019-11-30 21:05:45
问题 Qt5 introduced QMediaPlayer but it can't play youtube link (I want only music). What I found is that in Qt 4.8 (phonon) it could but in Qt5 I get error: Missing decoder for 'text/html'. GStreamer has no plugin for it It is pure translation from Polish output in Qt creator. Is it a matter of GStreamer plugin or should I download HTML content, find direct link to media and play it? Any idea? Code: mMediaPlayer.setMedia(QUrl("http://youtu.be/wVvoQIdD80U")); mMediaPlayer.play(); 回答1: Link to

PyQt5 Access Frames with QmediaPlayer

牧云@^-^@ 提交于 2019-11-28 05:17:21
问题 I am creating a program to play videos and then process them. I am able to play the videos with QMediaPlayer . How do I access specific frames as images or something similar. My end goal would be to format the video into a 4-d tensor of size [Num of frames, width_of_video, height_of_video, channels]. Here is the code that loads my video.: self.clear_layout(self.vlayout) videoItem = QVideoWidget() self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.mediaPlayer.durationChanged