spmyn
11th May 2016, 11:00
Hello,
I have a project that needs to display QLabel on top of a video. In order to do so, I figured out that I should use QGraphicsView to display a video.
Here is my code:
player = new QMediaPlayer;
playlist = new QMediaPlaylist(player);
item = new QGraphicsVideoItem;
playlist->addMedia(QUrl::fromLocalFile("path/to/video"));
playlist->setCurrentIndex(0);
playlist->setPlaybackMode(playlist->Loop);
player->setPlaylist(playlist);
player->play();
player->setVideoOutput(item);
scene = new QGraphicsScene;
ui->graphicsView->setScene(scene);
ui->graphicsView->scene()->addItem(item);
Everything works fine. The problem is my video runs in a loop and it flickers every time it starts a new loop.
How can I make it run smoothly?
I have a project that needs to display QLabel on top of a video. In order to do so, I figured out that I should use QGraphicsView to display a video.
Here is my code:
player = new QMediaPlayer;
playlist = new QMediaPlaylist(player);
item = new QGraphicsVideoItem;
playlist->addMedia(QUrl::fromLocalFile("path/to/video"));
playlist->setCurrentIndex(0);
playlist->setPlaybackMode(playlist->Loop);
player->setPlaylist(playlist);
player->play();
player->setVideoOutput(item);
scene = new QGraphicsScene;
ui->graphicsView->setScene(scene);
ui->graphicsView->scene()->addItem(item);
Everything works fine. The problem is my video runs in a loop and it flickers every time it starts a new loop.
How can I make it run smoothly?