18 lines
516 B
C++
18 lines
516 B
C++
|
#include "elevideo.h"
|
||
|
#include <QMediaPlayer>
|
||
|
|
||
|
EleVideo::EleVideo(QString path, QWidget *parent) : QVideoWidget{parent} {
|
||
|
setAspectRatioMode(Qt::IgnoreAspectRatio);
|
||
|
QMediaPlayer* player = new QMediaPlayer(this);
|
||
|
player->setMedia(QUrl::fromLocalFile(path));
|
||
|
player->setVideoOutput(this);
|
||
|
if(isVisible()) player->play();
|
||
|
}
|
||
|
|
||
|
void EleVideo::showEvent(QShowEvent *) {
|
||
|
((QMediaPlayer*)mediaObject())->play();
|
||
|
}
|
||
|
void EleVideo::hideEvent(QHideEvent *) {
|
||
|
((QMediaPlayer*)mediaObject())->stop();
|
||
|
}
|