Reputation: 1123
I tried to play video from a buffer and append the buffer while playing so the two or more videos play after each other without any delay as they are one video, I tried to use the QMediaPlaylist and append the list during run time, it worked but there is a Noticeable delay between the videos I use this code in the play button
void MainWindow::on_pushButton_2_clicked()
{
player = new QMediaPlayer(this);
QFile file("D:/video/first.mp4");
file.open(QIODevice::ReadOnly);
arr = new QByteArray();
arr->append(file.readAll());
file.close();
buffer = new QBuffer(arr);
buffer->open(QIODevice::ReadWrite);
player->setVideoOutput(ui->widget);
player->setMedia(QMediaContent(), buffer);
player->play();
}
and a button to append the second video during the runtime which is here I make many different trys
void MainWindow::on_pushButton_3_clicked()
{
QFile file("D:/video/second.mp4");
file.open(QIODevice::ReadOnly);
QByteArray temp = file.readAll();
//arr->append(temp, temp.size()); //first to append the QByteArray did not work
buffer->write(temp.data(), temp.size()); //second write to the buffer but not work
file.close();
qDebug() << "Appeneded";
}
first one which is append the array but it did not work, same as when i set the buffer to ReadWrite flage and its the same result, the result is that only the first video is played and it stop, so can you help me to make this work? what i did wrong in my code let the second video not run smoothly after first video and this is the result i want.
Upvotes: 0
Views: 1070