1 int main(int argc, char *argv[]) 2 { 3 QApplication a(argc, argv); 4 5 6 QWidget *widget = new QWidget; 7 widget->resize(400, 300); // 8 9 QVBoxLayout *layout = new QVBoxLayout; 10 QMediaPlayer* player = new QMediaPlayer; 11 QVideoWidget* vw = new QVideoWidget; 12 13 layout->addWidget(vw); 14 widget->setLayout(layout); 15 16 player->setVideoOutput(vw); 17 18 QFile file("123.mp4"); 19 if(!file.open(QIODevice::ReadOnly)) 20 qDebug() << "Could not open file"; 21 22 player->setMedia(QUrl::fromLocalFile("123.mp4")); 23 player->play(); 24 widget->show(); 25 26 return a.exec(); 27 }
出现问题
解决方法:
window 下下载k-lite 即可解决此类 转码问题
时间: 2024-11-05 18:32:37