-
Notifications
You must be signed in to change notification settings - Fork 0
/
playercontrols.h
57 lines (45 loc) · 1.29 KB
/
playercontrols.h
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
44
45
46
47
48
49
50
51
52
53
54
55
#include <QMediaPlayer>
#include <QWidget>
class QAbstractButton;
class QAbstractSlider;
class QComboBox;
class PlayerControls : public QWidget
{
Q_OBJECT
public:
PlayerControls(QWidget *parent = nullptr);
void keyPressEvent(QKeyEvent *event) ;
QMediaPlayer::State state() const;
int volume() const;
bool isMuted() const;//静音
qreal playbackRate() const;//倍速
public slots:
void setState(QMediaPlayer::State state);
void setVolume(int volume);
void setMuted(bool muted);
void setPlaybackRate(float rate);
void playClicked();
signals:
void play();
void pause();
void stop();
void next();
void previous();
void changeVolume(int volume);
void changeMuting(bool muting);
void changeRate(qreal rate);
private slots:
void muteClicked();
void updateRate();
void onVolumeSliderValueChanged();
private:
QMediaPlayer::State m_playerState = QMediaPlayer::StoppedState;
bool m_playerMuted = false;
QAbstractButton *m_playButton = nullptr;
QAbstractButton *m_stopButton = nullptr;
QAbstractButton *m_nextButton = nullptr;
QAbstractButton *m_previousButton = nullptr;
QAbstractButton *m_muteButton = nullptr;
QAbstractSlider *m_volumeSlider = nullptr;
QComboBox *m_rateBox = nullptr;
};