#pragma execution_character_set("utf-8") #include "widget.h" #include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); //本示例支持的是rtsp视频流(其他的一概不支持/没有做音视频同步) QStringList urls; urls << "http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4"; urls << "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"; urls << "rtsp://admin:Admin123456@192.168.0.15:554/media/video1"; ui->cboxUrl->addItems(urls); ui->cboxUrl->setCurrentIndex(0); } Widget::~Widget() { delete ui; } void Widget::on_btnOpen_clicked() { if (ui->btnOpen->text() == "打开") { ui->btnOpen->setText("关闭"); QString url = ui->cboxUrl->currentText().trimmed(); ui->playWidget->setUrl(url); ui->playWidget->open(); } else { ui->btnOpen->setText("打开"); ui->playWidget->close(); } }