Qmmp
statehandler.h
1 /***************************************************************************
2  * Copyright (C) 2008-2020 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef STATEHANDLER_H
21 #define STATEHANDLER_H
22 
23 #include <QObject>
24 #include <QMap>
25 #include <QHash>
26 #include <QMutex>
27 #include "abstractengine.h"
28 #include "audioparameters.h"
29 #include "qmmp.h"
30 
34 class QMMP_EXPORT StateHandler : public QObject
35 {
36  Q_OBJECT
37 public:
42  StateHandler(QObject *parent = nullptr);
46  ~StateHandler();
52  void dispatch(qint64 elapsed, int bitrate);
57  void dispatch(const AudioParameters &p);
62  void dispatch(qint64 duration);
67  bool dispatch(const TrackInfo &info);
71  void dispatch(const QHash<QString, QString> &info);
75  void dispatch(Qmmp::State state);
80  void dispatchBuffer(int percent);
84  qint64 elapsed() const;
88  qint64 duration() const;
92  int bitrate() const;
96  AudioParameters audioParameters() const;
100  Qmmp::State state() const;
104  void sendNextTrackRequest();
108  void sendFinished();
112  static StateHandler* instance();
113 
114 signals:
119  void elapsedChanged(qint64 time);
124  void bitrateChanged(int bitrate);
129  void audioParametersChanged(const AudioParameters &p);
134  void bufferingProgress(int progress);
135 
136 
137 private:
138  qint64 m_elapsed;
139  qint64 m_duration;
140  bool m_sendAboutToFinish;
141  int m_bitrate;
142  static StateHandler* m_instance;
143  TrackInfo m_info;
144  QHash <QString, QString> m_streamInfo;
145  Qmmp::State m_state;
146  AudioParameters m_audioParameters;
147  mutable QMutex m_mutex;
148 };
149 
150 #endif
State
Definition: qmmp.h:61
The AudioParameters class keeps information about audio settings.
Definition: audioparameters.h:31
The StateHandler class allows one to track information about playback progress.
Definition: statehandler.h:34
The TrackInfo class stores metadata and other information about track.
Definition: trackinfo.h:31