Qmmp
Loading...
Searching...
No Matches
statehandler.h
1/***************************************************************************
2 * Copyright (C) 2008-2022 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
34class QMMP_EXPORT StateHandler : public QObject
35{
36 Q_OBJECT
37public:
42 StateHandler(QObject *parent = nullptr);
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;
113
114signals:
119 void elapsedChanged(qint64 time);
124 void bitrateChanged(int bitrate);
134 void bufferingProgress(int progress);
135
136
137private:
138 qint64 m_elapsed = -1;
139 qint64 m_duration = 0;
140 bool m_sendAboutToFinish = true;
141 int m_bitrate = 0;
142 static StateHandler* m_instance;
143 TrackInfo m_info;
144 QHash <QString, QString> m_streamInfo;
145 Qmmp::State m_state = Qmmp::Stopped;
146 AudioParameters m_audioParameters;
147 mutable QMutex m_mutex;
148};
149
150#endif
The AudioParameters class keeps information about audio settings.
Definition audioparameters.h:32
State
Definition qmmp.h:62
@ Stopped
Definition qmmp.h:65
The StateHandler class allows one to track information about playback progress.
Definition statehandler.h:35
bool dispatch(const TrackInfo &info)
void sendNextTrackRequest()
void dispatch(const QHash< QString, QString > &info)
void bitrateChanged(int bitrate)
void sendFinished()
void bufferingProgress(int progress)
static StateHandler * instance()
Qmmp::State state() const
StateHandler(QObject *parent=nullptr)
void dispatch(qint64 duration)
void dispatch(const AudioParameters &p)
void dispatch(Qmmp::State state)
void audioParametersChanged(const AudioParameters &p)
void dispatchBuffer(int percent)
qint64 elapsed() const
qint64 duration() const
int bitrate() const
void elapsedChanged(qint64 time)
AudioParameters audioParameters() const
void dispatch(qint64 elapsed, int bitrate)
The TrackInfo class stores metadata and other information about track.
Definition trackinfo.h:32