,所以我希望它發揮了一定時間的視頻,所以play();
之後我使用的功能delay();
: 但它凍結流,所以我只得到聲音,沒有圖像???。 ,我不能使用計時器。延遲不結冰多媒體
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QVideoWidget *videoWidget = new QVideoWidget;
QBoxLayout *layout = new QVBoxLayout;
layout->addWidget(videoWidget);
ui->centralWidget->setLayout(layout);
p.setVideoOutput(videoWidget);
filename=QFileDialog::getOpenFileName(this,"select movie","/");
this->setWindowTitle(filename);
p.setMedia(QUrl::fromLocalFile(filename));
p.setPosition(300000);
p.play();
delay(4000);
p.setPosition(p.position()+1800000);
delay(4000);
p.setPosition(p.position()+1800000);
delay(4000);
}
void MainWindow:: delay(int millisecondsToWait)
{
QEventLoop loop;
QTimer::singleShot(millisecondsToWait, &loop, SLOT(quit()));
loop.exec();
}
毫不拖延地將正常運行的視頻,但我希望它發揮只有4秒每30分鐘,我只得到了音頻
爲什麼你不想使用'QTimer' +插槽,用於實現這樣的邏輯? –
不能使用計時器與插槽,它不工作在一個循環,我在循環中使用此代碼 –