TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
soundcore.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006-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 SOUNDCORE_H
22 #define SOUNDCORE_H
23 
24 #include <QQueue>
25 #include "decoder.h"
26 #include "output.h"
27 #include "visual.h"
28 #include "audioparameters.h"
29 #include "eqsettings.h"
30 #include "trackinfo.h"
31 
32 class VolumeHandler;
33 class AbstractEngine;
34 class InputSource;
35 class StateHandler;
36 
40 class QMMP_EXPORT SoundCore : public QObject
41 {
42  Q_OBJECT
43 public:
48  explicit SoundCore(QObject *parent = nullptr);
52  ~SoundCore();
53 
57  qint64 duration() const;
61  EqSettings eqSettings() const;
65  void setEqSettings(const EqSettings &settings);
69  int leftVolume() const;
73  int rightVolume() const;
77  int volume() const;
81  int balance() const;
85  bool isMuted() const;
89  qint64 elapsed() const;
93  int bitrate() const;
97  AudioParameters audioParameters() const;
101  Qmmp::State state() const;
105  const QMap<Qmmp::MetaData, QString> &metaData() const;
109  QString metaData(Qmmp::MetaData key) const;
113  const QHash<QString, QString> &streamInfo() const;
117  const TrackInfo &trackInfo() const;
122  bool nextTrackAccepted() const;
126  static SoundCore* instance();
127 
128 public slots:
134  void setVolume(int left, int right);
139  void setMuted(bool mute);
143  void changeVolume(int delta);
148  void setVolume(int volume);
152  void volumeUp();
156  void volumeDown();
161  void setBalance(int balance);
167  bool play(const QString &source, bool queue = false, qint64 offset = -1);
171  void stop();
175  void pause();
179  void seek(qint64 time);
183  QString path() const;
184 
185 signals:
190  void bufferingProgress(int progress);
195  void elapsedChanged(qint64 time);
200  void bitrateChanged(int bitrate);
205  void audioParametersChanged(const AudioParameters &p);
209  void streamInfoChanged();
213  void trackInfoChanged();
217  void stateChanged(Qmmp::State newState);
221  void finished();
226  void mutedChanged(bool muted);
231  void volumeChanged(int volume);
236  void balanceChanged(int balance);
240  void eqSettingsChanged();
244  void nextTrackRequest();
245 
246 private slots:
247  void startNextSource();
248  void startNextEngine();
249 
250 private:
251  virtual bool event(QEvent *e) override final;
252 
254  {
255  NO_ENGINE = 0,
258  INVALID_SOURCE
259  };
260 
261  QHash<QString, QString> m_streamInfo;
263  QString m_path;
265  StateHandler *m_handler = nullptr;
266  VolumeHandler *m_volumeControl = nullptr;
267  AbstractEngine *m_engine = nullptr;
268  QQueue<InputSource *> m_sources;
269  int m_nextState = NO_ENGINE;
270 
271 };
272 
273 #endif
QQueue< InputSource * > m_sources
Definition: soundcore.h:268
static SoundCore * m_instance
Definition: soundcore.h:264
static constexpr wchar_t key[]
The AudioParameters class keeps information about audio settings.
The StateHandler class allows one to track information about playback progress.
Definition: statehandler.h:32
The InputSource class provides the base interface class of transports.
Definition: inputsource.h:35
QHash< QString, QString > m_streamInfo
Definition: soundcore.h:261
voidpf uLong offset
Definition: ioapi.h:142
MetaData
Definition: qmmp.h:88
The TrackInfo class stores metadata and other information about track.
Definition: trackinfo.h:32
The EqSettings class helps to work with equalizer settings.
Definition: eqsettings.h:29
State
Definition: qmmp.h:76
The VolumeHandler class provides volume control access.
Definition: volumehandler.h:36
The AbstractEngine class provides the base interface class of audio audio engines.
#define QMMP_EXPORT
Definition: qmmp_export.h:29
QString m_path
Definition: soundcore.h:263
The SoundCore class provides a simple interface for audio playback.
Definition: soundcore.h:40
TrackInfo m_info
Definition: soundcore.h:262
state
Definition: http_parser.c:279