qt_demoe/video/playvlc/widget.cpp

46 lines
1.2 KiB
C++
Raw Normal View History

2020-04-22 06:36:41 +00:00
#pragma execution_character_set("utf-8")
#include "widget.h"
#include "ui_widget.h"
2020-08-27 07:38:19 +00:00
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
2020-04-22 06:36:41 +00:00
{
ui->setupUi(this);
QStringList urls;
2023-06-25 12:03:29 +00:00
urls << "http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4";
urls << "http://vd3.bdstatic.com/mda-jennyc5ci1ugrxzi/mda-jennyc5ci1ugrxzi.mp4";
2021-11-25 11:59:38 +00:00
urls << "rtsp://admin:Admin123456@192.168.0.15:554/media/video1";
2020-04-22 06:36:41 +00:00
ui->cboxUrl->addItems(urls);
2021-11-17 07:33:19 +00:00
ui->cboxUrl->setCurrentIndex(0);
2020-04-22 06:36:41 +00:00
}
Widget::~Widget()
{
delete ui;
}
2023-06-28 02:19:13 +00:00
void Widget::on_btnSelect_clicked()
{
QString fileName = QFileDialog::getOpenFileName();
if (!fileName.isEmpty()) {
ui->cboxUrl->addItem(fileName);
ui->cboxUrl->lineEdit()->setText(fileName);
if (ui->btnOpen->text() == "打开") {
on_btnOpen_clicked();
}
}
}
2020-04-22 06:36:41 +00:00
void Widget::on_btnOpen_clicked()
{
if (ui->btnOpen->text() == "打开") {
ui->btnOpen->setText("关闭");
QString url = ui->cboxUrl->currentText().trimmed();
2020-08-27 07:38:19 +00:00
ui->playWidget->setUrl(url);
ui->playWidget->open();
2020-04-22 06:36:41 +00:00
} else {
ui->btnOpen->setText("打开");
2020-08-27 07:38:19 +00:00
ui->playWidget->close();
2020-04-22 06:36:41 +00:00
}
}