Search code examples
qtc++17qt-creatorqt6

MP4 in background(MainWindow) qt6.3


I would like to know if there is any class that I can work with that accepts mp4, because the multimedia class is not active in qt6.3. I'm trying to load mp4 files in the background, but I didn't find classes in qt(6.3)


Solution

  • You can use QMediaPlayer for this.

    player = new QMediaPlayer;
    player->setSource(QUrl::fromLocalFile("/Users/lpapp/Music/song.mp4"));
    player->play();
    

    For video rendering, you can even use the QVideoWidget class:

    videoWidget = new QVideoWidget;
    player->setVideoOutput(videoWidget);
    videoWidget->show();