Qmmp
statehandler.h
1 /***************************************************************************
2  * Copyright (C) 2008-2018 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 = 0);
46  ~StateHandler();
52  void dispatch(qint64 elapsed, int bitrate);
57  void dispatch(const AudioParameters &p);
62  void dispatch(qint64 duration);
63 
64  bool dispatch(const TrackInfo &info);
68  void dispatch(const QHash<QString, QString> &info);
72  void dispatch(Qmmp::State state);
77  void dispatchBuffer(int percent);
81  qint64 elapsed() const;
85  qint64 duration() const;
89  int bitrate() const;
93  AudioParameters audioParameters() const;
97  Qmmp::State state() const;
101  void sendNextTrackRequest();
105  void sendFinished();
109  static StateHandler* instance();
110 
111 signals:
116  void elapsedChanged(qint64 time);
121  void bitrateChanged(int bitrate);
126  void audioParametersChanged(const AudioParameters &p);
131  void bufferingProgress(int progress);
132 
133 
134 private:
135  qint64 m_elapsed;
136  qint64 m_duration;
137  bool m_sendAboutToFinish;
138  int m_bitrate;
139  static StateHandler* m_instance;
140  QMap <Qmmp::MetaData, QString> m_metaData;
141  TrackInfo m_info;
142  QHash <QString, QString> m_streamInfo;
143  Qmmp::State m_state;
144  AudioParameters m_audioParameters;
145  mutable QMutex m_mutex;
146 };
147 
148 #endif
State
Definition: qmmp.h:52
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