#include "elevideo.h" #include "tools.h" #include #include #include EleVideo::EleVideo(QString path, QWidget *parent) : QWidget{parent} { auto glWgt = new QOpenGLWidget(this); glWgt->setGeometry(-1,-1,1,1); connect(glWgt, &QOpenGLWidget::frameSwapped, glWgt, (void(QOpenGLWidget::*)())&QOpenGLWidget::update); player = new FFPlayer(); connect(glWgt, &QOpenGLWidget::frameSwapped, player, &FFPlayer::updFrame); connect(player, &FFPlayer::emUpd, this, [this](QImage img) { this->img = img; update(); }); connect(player, &FFPlayer::emError, this, [this](QString err) { QMessageBox::critical(this, "Video Error", err); }); player->open(path.toUtf8()); } //void EleVideo::mouseDoubleClickEvent(QMouseEvent *) { // qDebug()<<"img"<img; // qDebug()<<"viCurTime"<viCurTime; // qDebug()<<"viSize"<viSize; //} void EleVideo::showEvent(QShowEvent *) { if(player!=nullptr) player->play(); } void EleVideo::hideEvent(QHideEvent *) { if(player!=nullptr) player->stop(); } void EleVideo::paintEvent(QPaintEvent *e) { QWidget::paintEvent(e); QPainter painter(this); painter.drawImage(QRectF(0, 0, width(), height()), img); }