|
@@ -20,6 +20,7 @@
|
|
#include "Base/FunctionTransfer.h"
|
|
#include "Base/FunctionTransfer.h"
|
|
|
|
|
|
#include "Widget/SetVideoUrlDialog.h"
|
|
#include "Widget/SetVideoUrlDialog.h"
|
|
|
|
+#include "Widget/mymessagebox_withTitle.h"
|
|
|
|
|
|
Q_DECLARE_METATYPE(VideoPlayerState)
|
|
Q_DECLARE_METATYPE(VideoPlayerState)
|
|
|
|
|
|
@@ -40,8 +41,27 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
//因为VideoPlayer::PlayerState是自定义的类型 要跨线程传递需要先注册一下
|
|
//因为VideoPlayer::PlayerState是自定义的类型 要跨线程传递需要先注册一下
|
|
qRegisterMetaType<VideoPlayerState>();
|
|
qRegisterMetaType<VideoPlayerState>();
|
|
|
|
|
|
|
|
+ mPopMenu = new QMenu(this);
|
|
|
|
+
|
|
|
|
+ mAddVideoAction = new QAction(QIcon("images/open.png"), QStringLiteral("打开网络流"), this);
|
|
|
|
+ mEditVideoAction = new QAction(QIcon("images/open.png"), QStringLiteral("修改数据"), this);
|
|
|
|
+ mDeleteVideoAction = new QAction(QIcon("images/open.png"), QStringLiteral("删除"), this);
|
|
|
|
+ mClearVideoAction = new QAction(QIcon("images/open.png"), QStringLiteral("清空"), this);
|
|
|
|
+
|
|
|
|
+ mPopMenu->addAction(mAddVideoAction);
|
|
|
|
+// mPopMenu->addAction(mEditVideoAction);
|
|
|
|
+// mPopMenu->addSeparator(); //添加分离器
|
|
|
|
+ mPopMenu->addAction(mDeleteVideoAction);
|
|
|
|
+ mPopMenu->addAction(mClearVideoAction);
|
|
|
|
+
|
|
|
|
+ connect(mAddVideoAction, &QAction::triggered, this, &MainWindow::slotActionClick);
|
|
|
|
+ connect(mEditVideoAction, &QAction::triggered, this, &MainWindow::slotActionClick);
|
|
|
|
+ connect(mDeleteVideoAction, &QAction::triggered, this, &MainWindow::slotActionClick);
|
|
|
|
+ connect(mClearVideoAction, &QAction::triggered, this, &MainWindow::slotActionClick);
|
|
|
|
+
|
|
connect(ui->pushButton_open, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->pushButton_open, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->toolButton_open, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->toolButton_open, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
|
|
+ connect(ui->pushButton_clear,&QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->pushButton_play, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->pushButton_play, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->pushButton_pause,&QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->pushButton_pause,&QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->pushButton_stop, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
connect(ui->pushButton_stop, &QPushButton::clicked, this, &MainWindow::slotBtnClick);
|
|
@@ -50,12 +70,21 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
connect(ui->horizontalSlider, SIGNAL(sig_valueChanged(int)), this, SLOT(slotSliderMoved(int)));
|
|
connect(ui->horizontalSlider, SIGNAL(sig_valueChanged(int)), this, SLOT(slotSliderMoved(int)));
|
|
connect(ui->horizontalSlider_volume, SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int)));
|
|
connect(ui->horizontalSlider_volume, SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int)));
|
|
|
|
|
|
|
|
+ ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
+
|
|
|
|
+ connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &MainWindow::slotItemDoubleClicked);
|
|
|
|
+ connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &MainWindow::slotCustomContextMenuRequested);
|
|
|
|
+
|
|
ui->page_video->setMouseTracking(true);
|
|
ui->page_video->setMouseTracking(true);
|
|
ui->widget_videoPlayer->setMouseTracking(true);
|
|
ui->widget_videoPlayer->setMouseTracking(true);
|
|
// ui->page_video->installEventFilter(this);
|
|
// ui->page_video->installEventFilter(this);
|
|
ui->widget_videoPlayer->installEventFilter(this);
|
|
ui->widget_videoPlayer->installEventFilter(this);
|
|
ui->widget_container->installEventFilter(this);
|
|
ui->widget_container->installEventFilter(this);
|
|
|
|
|
|
|
|
+ mCurrentIndex = 0;
|
|
|
|
+ mCurrentItem = nullptr;
|
|
|
|
+ mIsNeedPlayNext = false;
|
|
|
|
+
|
|
mPlayer = new VideoPlayer();
|
|
mPlayer = new VideoPlayer();
|
|
mPlayer->setVideoPlayerCallBack(this);
|
|
mPlayer->setVideoPlayerCallBack(this);
|
|
|
|
|
|
@@ -77,6 +106,37 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
|
|
mVolume = mPlayer->getVolume();
|
|
mVolume = mPlayer->getVolume();
|
|
|
|
|
|
|
|
+ std::thread([=]
|
|
|
|
+ {
|
|
|
|
+ while (1)
|
|
|
|
+ {
|
|
|
|
+ AppConfig::mSleep(500);
|
|
|
|
+
|
|
|
|
+ static QPoint lastPoint = QPoint(0, 0);
|
|
|
|
+
|
|
|
|
+ FunctionTransfer::runInMainThread([=]()
|
|
|
|
+ {
|
|
|
|
+ QPoint point = QCursor::pos();
|
|
|
|
+
|
|
|
|
+ if (this->geometry().contains(point))
|
|
|
|
+ {
|
|
|
|
+ if (lastPoint != point)
|
|
|
|
+ {
|
|
|
|
+ if (!mTimer_CheckControlWidget->isActive())
|
|
|
|
+ {
|
|
|
|
+ showOutControlWidget();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mTimer_CheckControlWidget->stop();
|
|
|
|
+ mTimer_CheckControlWidget->start();
|
|
|
|
+
|
|
|
|
+ lastPoint = point;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }).detach();
|
|
}
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
MainWindow::~MainWindow()
|
|
@@ -139,6 +199,109 @@ void MainWindow::hideControlWidget()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+void MainWindow::setVideoNums(const int &nums)
|
|
|
|
+{
|
|
|
|
+ ui->label_num->setText(QStringLiteral("%1个文件").arg(nums));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::addVideoFiles(const QStringList &videoFileList)
|
|
|
|
+{
|
|
|
|
+ if (!videoFileList.isEmpty())
|
|
|
|
+ {
|
|
|
|
+ QString filePath = videoFileList.first();
|
|
|
|
+ AppConfig::gVideoFilePath = QFileInfo(filePath).absoluteDir().path();
|
|
|
|
+ AppConfig::saveConfigInfoToFile();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (QString filePath : videoFileList)
|
|
|
|
+ {
|
|
|
|
+ addVideoFile(filePath);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::addVideoFile(const QString &filePath)
|
|
|
|
+{
|
|
|
|
+ QFileInfo fileInfo(filePath);
|
|
|
|
+
|
|
|
|
+ QListWidgetItem *item = new QListWidgetItem();
|
|
|
|
+ item->setText(fileInfo.fileName());
|
|
|
|
+ ui->listWidget->addItem(item);
|
|
|
|
+
|
|
|
|
+ mVideoFileList.append(filePath);
|
|
|
|
+
|
|
|
|
+ setVideoNums(mVideoFileList.size());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::clear()
|
|
|
|
+{
|
|
|
|
+ stopPlay();
|
|
|
|
+ ui->listWidget->clear();
|
|
|
|
+ mVideoFileList.clear();
|
|
|
|
+
|
|
|
|
+ setVideoNums(mVideoFileList.size());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::startPlay()
|
|
|
|
+{
|
|
|
|
+ playVideo(0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::stopPlay()
|
|
|
|
+{
|
|
|
|
+ if (mCurrentItem != nullptr)
|
|
|
|
+ {
|
|
|
|
+ mCurrentItem->setBackgroundColor(QColor(0, 0, 0, 0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mCurrentItem = nullptr;
|
|
|
|
+
|
|
|
|
+ mIsNeedPlayNext = false;
|
|
|
|
+ mPlayer->stop(true);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::playVideo(const int &index)
|
|
|
|
+{
|
|
|
|
+ int playIndex = index;
|
|
|
|
+
|
|
|
|
+// ///播放到最后一个后,从头开始播放
|
|
|
|
+// {
|
|
|
|
+// if ((playIndex < 0) || (mVideoFileList.size() <= playIndex))
|
|
|
|
+// {
|
|
|
|
+// playIndex = 0;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ if (index >= 0 && mVideoFileList.size() > playIndex)
|
|
|
|
+ {
|
|
|
|
+ mCurrentIndex = playIndex;
|
|
|
|
+
|
|
|
|
+ QString filePath = mVideoFileList.at(playIndex);
|
|
|
|
+
|
|
|
|
+qDebug()<<__FUNCTION__<<filePath<<playIndex;
|
|
|
|
+
|
|
|
|
+ playVideoFile(filePath);
|
|
|
|
+
|
|
|
|
+// ui->listWidget->setCurrentRow(playIndex);
|
|
|
|
+ QListWidgetItem *item = ui->listWidget->item(playIndex);
|
|
|
|
+
|
|
|
|
+ if (mCurrentItem != nullptr)
|
|
|
|
+ {
|
|
|
|
+ mCurrentItem->setBackgroundColor(QColor(0, 0, 0, 0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mCurrentItem = item;
|
|
|
|
+
|
|
|
|
+ mCurrentItem->setBackgroundColor(QColor(75, 92, 196));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::playVideoFile(const QString &filePath)
|
|
|
|
+{
|
|
|
|
+ mIsNeedPlayNext = false;
|
|
|
|
+ mPlayer->stop(true);
|
|
|
|
+ mPlayer->startPlay(filePath.toStdString());
|
|
|
|
+}
|
|
|
|
+
|
|
void MainWindow::slotSliderMoved(int value)
|
|
void MainWindow::slotSliderMoved(int value)
|
|
{
|
|
{
|
|
if (QObject::sender() == ui->horizontalSlider)
|
|
if (QObject::sender() == ui->horizontalSlider)
|
|
@@ -182,40 +345,155 @@ void MainWindow::slotTimerTimeOut()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void MainWindow::slotBtnClick(bool isChecked)
|
|
|
|
|
|
+
|
|
|
|
+void MainWindow::doAdd()
|
|
{
|
|
{
|
|
- if (QObject::sender() == ui->pushButton_play)
|
|
|
|
|
|
+ QStringList fileList = QFileDialog::getOpenFileNames(
|
|
|
|
+ this, QStringLiteral("选择要播放的文件"),
|
|
|
|
+ AppConfig::gVideoFilePath,//初始目录
|
|
|
|
+ QStringLiteral("视频文件 (*.flv *.rmvb *.avi *.MP4 *.mkv);;")
|
|
|
|
+ +QStringLiteral("音频文件 (*.mp3 *.wma *.wav);;")
|
|
|
|
+ +QStringLiteral("所有文件 (*.*)"));
|
|
|
|
+
|
|
|
|
+ if (!fileList.isEmpty())
|
|
{
|
|
{
|
|
- mPlayer->play();
|
|
|
|
|
|
+ addVideoFiles(fileList);
|
|
}
|
|
}
|
|
- else if (QObject::sender() == ui->pushButton_pause)
|
|
|
|
|
|
+
|
|
|
|
+ ///第一次添加,则直接播放
|
|
|
|
+ if (mVideoFileList.size() == fileList.size())
|
|
{
|
|
{
|
|
- mPlayer->pause();
|
|
|
|
|
|
+ startPlay();
|
|
}
|
|
}
|
|
- else if (QObject::sender() == ui->pushButton_stop)
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::doAddStream()
|
|
|
|
+{
|
|
|
|
+ SetVideoUrlDialog dialog;
|
|
|
|
+
|
|
|
|
+// dialog.setVideoUrl(AppConfig::gVideoFilePath);
|
|
|
|
+
|
|
|
|
+ if (dialog.exec() == QDialog::Accepted)
|
|
{
|
|
{
|
|
- mPlayer->stop(true);
|
|
|
|
|
|
+ QString s = dialog.getVideoUrl();
|
|
|
|
+
|
|
|
|
+ if (!s.isEmpty())
|
|
|
|
+ {
|
|
|
|
+ mIsNeedPlayNext = false;
|
|
|
|
+ mPlayer->stop(true); //如果在播放则先停止
|
|
|
|
+ mPlayer->startPlay(s.toStdString());
|
|
|
|
+
|
|
|
|
+ AppConfig::gVideoFilePath = s;
|
|
|
|
+ AppConfig::saveConfigInfoToFile();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::doDelete()
|
|
|
|
+{
|
|
|
|
+ QList<int> RowList;
|
|
|
|
+
|
|
|
|
+ QList<QListWidgetItem*> selectedItemList = ui->listWidget->selectedItems();
|
|
|
|
+
|
|
|
|
+ for (QListWidgetItem* item : selectedItemList)
|
|
|
|
+ {
|
|
|
|
+ int rowValue = ui->listWidget->row(item);
|
|
|
|
+
|
|
|
|
+ int index = RowList.size();
|
|
|
|
+ for (int i=0;i<RowList.size();i++)
|
|
|
|
+ {
|
|
|
|
+ int value = RowList.at(i);
|
|
|
|
+
|
|
|
|
+ if (rowValue > value)
|
|
|
|
+ {
|
|
|
|
+ index = i;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ RowList.insert(index, rowValue);
|
|
}
|
|
}
|
|
- else if (QObject::sender() == ui->pushButton_open || QObject::sender() == ui->toolButton_open)
|
|
|
|
|
|
+qDebug()<<__FUNCTION__<<RowList;
|
|
|
|
+ if (RowList.isEmpty())
|
|
{
|
|
{
|
|
- SetVideoUrlDialog dialog;
|
|
|
|
|
|
+ int ret = MyMessageBox_WithTitle::showWarningText(QStringLiteral("警告"),
|
|
|
|
+ QStringLiteral("请先选择需要删除的数据!"),
|
|
|
|
+ NULL,
|
|
|
|
+ QStringLiteral("关闭"));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- dialog.setVideoUrl(AppConfig::gVideoFilePath);
|
|
|
|
|
|
+ int ret = MyMessageBox_WithTitle::showWarningText(QStringLiteral("警告"),
|
|
|
|
+ QStringLiteral("确定删除这%1条数据么?").arg(RowList.size()),
|
|
|
|
+ QStringLiteral("确定"),
|
|
|
|
+ QStringLiteral("取消"));
|
|
|
|
|
|
- if (dialog.exec() == QDialog::Accepted)
|
|
|
|
|
|
+ if (ret == QDialog::Accepted)
|
|
|
|
+ {
|
|
|
|
+ for(int i=0; i<RowList.size(); i++)
|
|
{
|
|
{
|
|
- QString s = dialog.getVideoUrl();
|
|
|
|
|
|
+ int row = RowList.at(i);
|
|
|
|
+
|
|
|
|
+ mVideoFileList.removeAt(i);
|
|
|
|
+
|
|
|
|
+ QListWidgetItem *item = ui->listWidget->takeItem(row);
|
|
|
|
|
|
- if (!s.isEmpty())
|
|
|
|
|
|
+ if (mCurrentItem == item)
|
|
{
|
|
{
|
|
- mPlayer->stop(true); //如果在播放则先停止
|
|
|
|
- mPlayer->startPlay(s.toStdString());
|
|
|
|
|
|
+ mCurrentItem = nullptr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ delete item;
|
|
|
|
|
|
- AppConfig::gVideoFilePath = s;
|
|
|
|
- AppConfig::saveConfigInfoToFile();
|
|
|
|
|
|
+ if (row <= mCurrentIndex)
|
|
|
|
+ {
|
|
|
|
+ mCurrentIndex --;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setVideoNums(mVideoFileList.size());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::doClear()
|
|
|
|
+{
|
|
|
|
+ int ret = MyMessageBox_WithTitle::showWarningText(QStringLiteral("警告"),
|
|
|
|
+ QStringLiteral("确定要清空所有数据么?"),
|
|
|
|
+ QStringLiteral("确定"),
|
|
|
|
+ QStringLiteral("取消"));
|
|
|
|
+
|
|
|
|
+ if (ret == QDialog::Accepted)
|
|
|
|
+ {
|
|
|
|
+ clear();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
|
|
+void MainWindow::slotBtnClick(bool isChecked)
|
|
|
|
+{
|
|
|
|
+ if (QObject::sender() == ui->pushButton_play)
|
|
|
|
+ {
|
|
|
|
+ mPlayer->play();
|
|
|
|
+ }
|
|
|
|
+ else if (QObject::sender() == ui->pushButton_pause)
|
|
|
|
+ {
|
|
|
|
+ mPlayer->pause();
|
|
|
|
+ }
|
|
|
|
+ else if (QObject::sender() == ui->pushButton_stop)
|
|
|
|
+ {
|
|
|
|
+ mIsNeedPlayNext = false;
|
|
|
|
+ mPlayer->stop(true);
|
|
|
|
+ }
|
|
|
|
+ else if (QObject::sender() == ui->pushButton_open)
|
|
|
|
+ {
|
|
|
|
+ doAdd();
|
|
|
|
+ }
|
|
|
|
+ else if (QObject::sender() == ui->pushButton_clear)
|
|
|
|
+ {
|
|
|
|
+ doClear();
|
|
|
|
+ }
|
|
|
|
+ else if (QObject::sender() == ui->toolButton_open)
|
|
|
|
+ {
|
|
|
|
+ doAddStream();
|
|
}
|
|
}
|
|
else if (QObject::sender() == ui->pushButton_volume)
|
|
else if (QObject::sender() == ui->pushButton_volume)
|
|
{
|
|
{
|
|
@@ -244,6 +522,68 @@ void MainWindow::slotBtnClick(bool isChecked)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+void MainWindow::slotItemDoubleClicked(QListWidgetItem *item)
|
|
|
|
+{
|
|
|
|
+ if (QObject::sender() == ui->listWidget)
|
|
|
|
+ {
|
|
|
|
+ int index = ui->listWidget->row(item);
|
|
|
|
+ playVideo(index);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::slotCustomContextMenuRequested()
|
|
|
|
+{
|
|
|
|
+// QPoint point(ui->listWidget->mapFromGlobal(QCursor::pos()));//获取控件的全局坐标
|
|
|
|
+
|
|
|
|
+// int h = ui->tableWidget->horizontalHeader()->height();
|
|
|
|
+
|
|
|
|
+// point.setY(point.y() - h);
|
|
|
|
+
|
|
|
|
+// QTableWidgetItem *item = ui->tableWidget->itemAt(point);
|
|
|
|
+
|
|
|
|
+// if (item == NULL || !item->isSelected())
|
|
|
|
+// {
|
|
|
|
+// ui->tableWidget->clearSelection();
|
|
|
|
+
|
|
|
|
+// mAddUserAction->setEnabled(true);
|
|
|
|
+// mEditUserAction->setEnabled(false);
|
|
|
|
+// mDeleteUserAction->setEnabled(false);
|
|
|
|
+// mExportAction->setEnabled(false);
|
|
|
|
+// mUploadAction_Selected->setEnabled(false);
|
|
|
|
+// }
|
|
|
|
+// else
|
|
|
|
+// {
|
|
|
|
+// mAddUserAction->setEnabled(false);
|
|
|
|
+// mEditUserAction->setEnabled(true);
|
|
|
|
+// mDeleteUserAction->setEnabled(true);
|
|
|
|
+// mExportAction->setEnabled(true);
|
|
|
|
+// mUploadAction_Selected->setEnabled(true);
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ mPopMenu->exec(QCursor::pos());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MainWindow::slotActionClick()
|
|
|
|
+{
|
|
|
|
+ if (QObject::sender() == mAddVideoAction)
|
|
|
|
+ {
|
|
|
|
+ doAddStream();
|
|
|
|
+ }
|
|
|
|
+ else if (QObject::sender() == mEditVideoAction)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else if (QObject::sender() == mDeleteVideoAction)
|
|
|
|
+ {
|
|
|
|
+ doDelete();
|
|
|
|
+ }
|
|
|
|
+ else if (QObject::sender() == mClearVideoAction)
|
|
|
|
+ {
|
|
|
|
+ doClear();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
///打开文件失败
|
|
///打开文件失败
|
|
void MainWindow::onOpenVideoFileFailed(const int &code)
|
|
void MainWindow::onOpenVideoFileFailed(const int &code)
|
|
{
|
|
{
|
|
@@ -293,6 +633,7 @@ void MainWindow::onPlayerStateChanged(const VideoPlayerState &state, const bool
|
|
{
|
|
{
|
|
FunctionTransfer::runInMainThread([=]()
|
|
FunctionTransfer::runInMainThread([=]()
|
|
{
|
|
{
|
|
|
|
+qDebug()<<__FUNCTION__<<state<<mIsNeedPlayNext;
|
|
if (state == VideoPlayer_Stop)
|
|
if (state == VideoPlayer_Stop)
|
|
{
|
|
{
|
|
ui->stackedWidget->setCurrentWidget(ui->page_open);
|
|
ui->stackedWidget->setCurrentWidget(ui->page_open);
|
|
@@ -306,6 +647,13 @@ void MainWindow::onPlayerStateChanged(const VideoPlayerState &state, const bool
|
|
|
|
|
|
mTimer->stop();
|
|
mTimer->stop();
|
|
|
|
|
|
|
|
+ if (mIsNeedPlayNext)
|
|
|
|
+ {
|
|
|
|
+ mCurrentIndex++;
|
|
|
|
+ playVideo(mCurrentIndex);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mIsNeedPlayNext = true;
|
|
}
|
|
}
|
|
else if (state == VideoPlayer_Playing)
|
|
else if (state == VideoPlayer_Playing)
|
|
{
|
|
{
|
|
@@ -322,6 +670,8 @@ void MainWindow::onPlayerStateChanged(const VideoPlayerState &state, const bool
|
|
ui->pushButton_pause->show();
|
|
ui->pushButton_pause->show();
|
|
|
|
|
|
mTimer->start();
|
|
mTimer->start();
|
|
|
|
+
|
|
|
|
+ mIsNeedPlayNext = true;
|
|
}
|
|
}
|
|
else if (state == VideoPlayer_Pause)
|
|
else if (state == VideoPlayer_Pause)
|
|
{
|
|
{
|
|
@@ -337,6 +687,11 @@ void MainWindow::onDisplayVideo(std::shared_ptr<VideoFrame> videoFrame)
|
|
ui->widget_videoPlayer->inputOneFrame(videoFrame);
|
|
ui->widget_videoPlayer->inputOneFrame(videoFrame);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
+{
|
|
|
|
+ mPlayer->stop(true);
|
|
|
|
+}
|
|
|
|
+
|
|
//图片显示部件时间过滤器处理
|
|
//图片显示部件时间过滤器处理
|
|
bool MainWindow::eventFilter(QObject *target, QEvent *event)
|
|
bool MainWindow::eventFilter(QObject *target, QEvent *event)
|
|
{
|
|
{
|
|
@@ -350,8 +705,8 @@ bool MainWindow::eventFilter(QObject *target, QEvent *event)
|
|
QResizeEvent * e = (QResizeEvent*)event;
|
|
QResizeEvent * e = (QResizeEvent*)event;
|
|
int w = e->size().width();
|
|
int w = e->size().width();
|
|
int h = e->size().height();
|
|
int h = e->size().height();
|
|
- ui->stackedWidget->move(0, 0);
|
|
|
|
- ui->stackedWidget->resize(w, h);
|
|
|
|
|
|
+ ui->widget_video_back->move(0, 0);
|
|
|
|
+ ui->widget_video_back->resize(w, h);
|
|
|
|
|
|
int x = 0;
|
|
int x = 0;
|
|
int y = h - ui->widget_controller->height();
|
|
int y = h - ui->widget_controller->height();
|