-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreen.cpp
More file actions
43 lines (36 loc) · 949 Bytes
/
Screen.cpp
File metadata and controls
43 lines (36 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <QtWidgets>
#include <QVideoWidget>
#include "Screen.h"
Screen::Screen(QWidget *parent):
QLabel(parent)
, m_player( new QMediaPlayer(this))
{
setScaledContents(true);
}
void Screen::LoadFile(const QString &filePath)
{
QString fileSuffix = QFileInfo(filePath).suffix();
if (fileSuffix == "jpeg" || fileSuffix == "jpg")
{
setPixmap(QPixmap(filePath));
}
else if (fileSuffix == "avi")
{
m_player->setAudioRole(QAudio::VideoRole);
m_player->setMedia(QUrl::fromLocalFile(filePath));
QVideoWidget* videoWidget = new QVideoWidget(this);
m_player->setVideoOutput(videoWidget);
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(videoWidget);
setLayout(layout);
m_player->play();
}
}
void Screen::keyPressEvent(QKeyEvent* /*event*/)
{
if(m_player->isAvailable())
{
m_player->stop();
}
close();
}