Qt 5.10 Book Examples
VideoPlayer.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // VideoPlayer.cpp
3 // ======================================================================
4 // This file is a part of the book
5 // "Qt 5.10 Professional programming with C++"
6 // http://qt-book.com
7 // ======================================================================
8 // Copyright (c) 2017 by Max Schlee
9 // ======================================================================
10 
11 #include <QtWidgets>
12 #include <QVideoWidget>
13 
14 #include "VideoPlayer.h"
15 
16 // ----------------------------------------------------------------------
17 VideoPlayer::VideoPlayer(QWidget* pwgt/*=0*/) : SoundPlayer(pwgt)
18 {
19 
20  QVideoWidget* pvw = new QVideoWidget;
21  pvw->setMinimumSize(300, 300);
22 
23  m_pvbxMainLayout->addWidget(pvw);
24 
25  m_pmp->setVideoOutput(pvw);
26 
28  connect(m_pmp, SIGNAL(stateChanged(QMediaPlayer::State)),
29  SLOT(slotStateChanged(QMediaPlayer::State)));
30 }
31 
33 // ----------------------------------------------------------------------
34 void
35 VideoPlayer::slotStateChanged(QMediaPlayer::State st)
36 {
37  if (st == QMediaPlayer::PlayingState) {
38  resize(size() + QSize(1, 1));
39  resize(size() - QSize(1, 1));
40  }
41 }
QVBoxLayout * m_pvbxMainLayout
Definition: SoundPlayer.h:25
VideoPlayer(QWidget *pwgt=0)
Definition: VideoPlayer.cpp:17
QMediaPlayer * m_pmp
Definition: SoundPlayer.h:24