TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
statehandler.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2008-2024 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 
21 #ifndef STATEHANDLER_H
22 #define STATEHANDLER_H
23 
24 #include <QHash>
25 #include <QMutex>
26 #include "abstractengine.h"
27 #include "audioparameters.h"
28 
32 class QMMP_EXPORT StateHandler : public QObject
33 {
34  Q_OBJECT
35 public:
40  explicit StateHandler(QObject *parent = nullptr);
44  ~StateHandler();
45 
51  void dispatch(qint64 elapsed, int bitrate);
56  void dispatch(const AudioParameters &p);
61  void dispatch(qint64 duration);
66  bool dispatch(const TrackInfo &info);
70  void dispatch(const QHash<QString, QString> &info);
74  void dispatch(Qmmp::State state);
79  void dispatchBuffer(int percent);
83  qint64 elapsed() const;
87  qint64 duration() const;
91  int bitrate() const;
95  AudioParameters audioParameters() const;
99  Qmmp::State state() const;
103  void sendNextTrackRequest();
107  void sendFinished();
111  static StateHandler* instance();
112 
113 signals:
118  void elapsedChanged(qint64 time);
123  void bitrateChanged(int bitrate);
128  void audioParametersChanged(const AudioParameters &p);
133  void bufferingProgress(int progress);
134 
135 private:
136  qint64 m_elapsed = -1;
137  qint64 m_duration = 0;
138  bool m_sendAboutToFinish = true;
139  int m_bitrate = 0;
142  QHash<QString, QString> m_streamInfo;
145  mutable QMutex m_mutex;
146 
147 };
148 
149 #endif
AudioParameters m_audioParameters
Definition: statehandler.h:144
The AudioParameters class keeps information about audio settings.
The StateHandler class allows one to track information about playback progress.
Definition: statehandler.h:32
QMutex m_mutex
Definition: statehandler.h:145
The TrackInfo class stores metadata and other information about track.
Definition: trackinfo.h:32
State
Definition: qmmp.h:76
#define QMMP_EXPORT
Definition: qmmp_export.h:29
TrackInfo m_info
Definition: statehandler.h:141
static StateHandler * m_instance
Definition: statehandler.h:140
state
Definition: http_parser.c:279
QHash< QString, QString > m_streamInfo
Definition: statehandler.h:142