Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Qt5, QMediaPlayer]: Tiny duration black screen when the current source changed



  • I'm writing a Video Player with Qt5::QMediaPlayer:
    int main(int argc, char argv[]) {
    QApplication a(argc, argv);
    QMediaPlaylist
    playlist = new QMediaPlaylist;
    playlist->addMedia(QUrl::fromLocalFile(".\Resources\fractal-files\A-060405V4651.WMV"));
    playlist->addMedia(QUrl::fromLocalFile(".\Resources\fractal-files\B-101604.WMV"));
    playlist->addMedia(QUrl::fromLocalFile(".\Resources\fractal-files\C-102304.WMV"));
    int current(0);
    playlist->setCurrentIndex(current++);
    QMediaPlayer* player = new QMediaPlayer;
    player->setPlaylist(playlist);
    player->setVolume(50);
    QVideoWidget* videoWidget = new QVideoWidget;
    player->setVideoOutput(videoWidget);
    videoWidget->show();
    player->play();
    QPushButton* b = new QPushButton;
    QObject::connect(b, &QPushButton::clicked, &{
    if(current > 2) current = 0;
    playlist->setCurrentIndex(current++);
    player->play();
    });
    b->show();
    return a.exec();
    }

    When the button is clicked, I will change the video source. But there are a very small duration black screen gap when switching. If I let the app switches to the next video automatic, there are no black screen gap.

    How can I make this with no black screen gap (smoothly)?
    Thank you very much!





  • Thanks hpollak! I tried:
    // QMediaGaplessPlaybackControl *gapless = qobject_cast<QMediaGaplessPlaybackControl *>(
    // player->service()->requestControl("org.qt-project.qt.mediagaplessplaybackcontrol/5.0"));
    QMediaGaplessPlaybackControl gapless = player->service()->requestControl<QMediaGaplessPlaybackControl>();
    if(!gapless) {
    qDebug() << "no QMediaGaplessPlaybackControl";
    return -1;
    }

    But the result is a null pointer. I'm using Windows 8.1. Can you give me another hint?
    Thank you very much!



  • It seems that QMediaGaplessPlaybackControl is just an interface with no implementation. How can and what's needed to implement this interface?


Log in to reply