QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsmediawidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmediawidget.h
3
4 ---------------------
5 begin : 2023.01.24
6 copyright : (C) 2023 by Mathieu Pellerin
7 email : mathieu at opengis dot ch
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSMEDIAWIDGET_H
18#define QGSMEDIAWIDGET_H
19
20#include <QWidget>
21#include <QMediaPlayer>
22
23#include "qgis_gui.h"
24#include "qgis_sip.h"
25
26class QLabel;
27class QVBoxLayout;
28class QVideoWidget;
29class QPushButton;
30class QSlider;
31
37class GUI_EXPORT QgsMediaWidget : public QWidget
38{
39 Q_OBJECT
40
41 public:
45 enum Mode
46 {
49 };
50 Q_ENUM( Mode )
51
52
53 explicit QgsMediaWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
54
58 QString mediaPath() const { return mMediaPath; }
59
63 void setMediaPath( const QString &path );
64
68 Mode mode() const { return mMode; }
69
73 void setMode( Mode mode );
74
78 int videoHeight() const;
79
85 void setVideoHeight( int height );
86
90 QMediaPlayer *mediaPlayer() { return &mMediaPlayer; }
91
92 private slots:
93
94 void mediaStatusChanged( QMediaPlayer::MediaStatus status );
95
96 private:
97 void adjustControls();
98 void setControlsEnabled( bool enabled );
99
100 Mode mMode = Audio;
101
102 QVBoxLayout *mLayout = nullptr;
103 QVideoWidget *mVideoWidget = nullptr;
104 QPushButton *mPlayButton = nullptr;
105 QSlider *mPositionSlider = nullptr;
106 QLabel *mDurationLabel = nullptr;
107
108 QMediaPlayer mMediaPlayer;
109
110 QString mMediaPath;
111};
112
113#endif // QGSMEDIAWIDGET_H
The QgsMediaWidget class creates a widget for playing back audio and video media files.
Mode mode() const
Returns the media widget mode.
Mode
The mode determines the user interface elements visible within the widget.
@ Video
Video-centric user interface.
@ Audio
Audio-centric user interface.
QMediaPlayer * mediaPlayer()
Returns the QMediaPlayer object.
QString mediaPath() const
Returns the media path.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53