QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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
40 Q_OBJECT
41
42 public:
43
47 enum Mode
48 {
51 };
52 Q_ENUM( Mode )
53
54
55 explicit QgsMediaWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
56
60 QString mediaPath() const { return mMediaPath; }
61
65 void setMediaPath( const QString &path );
66
70 Mode mode() const { return mMode; }
71
75 void setMode( Mode mode );
76
80 int videoHeight() const;
81
87 void setVideoHeight( int height );
88
92 QMediaPlayer *mediaPlayer() { return &mMediaPlayer; }
93
94 private slots:
95
96 void mediaStatusChanged( QMediaPlayer::MediaStatus status );
97
98 private:
99
100 void adjustControls();
101 void setControlsEnabled( bool enabled );
102
103 Mode mMode = Audio;
104
105 QVBoxLayout *mLayout = nullptr;
106 QVideoWidget *mVideoWidget = nullptr;
107 QPushButton *mPlayButton = nullptr;
108 QSlider *mPositionSlider = nullptr;
109 QLabel *mDurationLabel = nullptr;
110
111 QMediaPlayer mMediaPlayer;
112
113 QString mMediaPath;
114
115};
116
117#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