-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqmyvideowidget.cpp
29 lines (29 loc) · 959 Bytes
/
qmyvideowidget.cpp
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
#include"qmyvideowidget.h"
#include<QKeyEvent>
#include<QMouseEvent>
#include<QLabel>
void QmyVideoWidget::keyPressEvent(QKeyEvent *event){
if ((event->key() == Qt::Key_Escape)&&(isFullScreen())){
setFullScreen(false);
event->accept();
}
if ((event->key() == Qt::Key_Space)){
if (thePlayer->state()==QMediaPlayer::PlayingState)thePlayer->pause();
else thePlayer->play();
event->accept();
}
QVideoWidget::keyPressEvent(event);
}
void QmyVideoWidget::mousePressEvent(QMouseEvent *event){
if (event->button()==Qt::LeftButton){
if (thePlayer->state()==QMediaPlayer::PlayingState)thePlayer->pause();
else thePlayer->play();
}
QVideoWidget::mousePressEvent(event);
}
QmyVideoWidget::QmyVideoWidget(QWidget *parent):QVideoWidget(parent){
this->grabKeyboard();
}
void QmyVideoWidget::setMediaPlayer(QMediaPlayer *player){
thePlayer=player;
}