TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicplayer.h
Go to the documentation of this file.
1 #ifndef MUSICPLAYER_H
2 #define MUSICPLAYER_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2026 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QTimer>
23 #include "musicglobaldefine.h"
24 
25 class SoundCore;
26 class MusicPlaylist;
27 
31 namespace TTK
32 {
33  enum class Enhance
34  {
35  Off,
36  M3D,
37  NICAM,
38  Subwoofer,
39  Vocal
40  };
41 }
42 
46 class TTK_MODULE_EXPORT MusicPlayer : public QObject
47 {
48  Q_OBJECT
50 public:
54  explicit MusicPlayer(QObject *parent = nullptr);
58  ~MusicPlayer();
59 
63  bool isPlaying() const noexcept;
67  TTK::PlayState state() const noexcept;
68 
72  void setPlaylist(MusicPlaylist *playlist) noexcept;
73 
77  qint64 duration() const;
81  qint64 position() const;
85  void setPosition(qint64 position);
86 
90  int volume() const;
94  void setVolume(int volume);
98  bool isMuted() const noexcept;
102  void setMuted(bool muted);
103 
107  void setEnhance(TTK::Enhance type);
111  TTK::Enhance enhance() const noexcept;
112 
113 Q_SIGNALS:
117  void stateChanged(TTK::PlayState state);
121  void durationChanged(qint64 duration);
125  void positionChanged(qint64 position);
126 
127 public Q_SLOTS:
131  void play();
135  void pause();
139  void stop();
143  void setEqualizerEffect(const TTKIntList &hz);
147  void setEnabledEffect(bool enabled);
151  void setEqualizerConfig();
152 
153 private Q_SLOTS:
157  void update();
161  void generateDuration();
162 
163 private:
167  void setStopState();
171  void setCurrentPlayState(TTK::PlayState state) noexcept;
172 
176  QTimer m_timer;
177  QString m_currentMedia;
178  qint64 m_duration;
180 
181  struct Data
182  {
184  int m_volume3D = 0;
185  float m_circlePos = 0;
186 
187  } m_enhance;
188 
189 };
190 
191 #endif // MUSICPLAYER_H
#define TTK_MODULE_EXPORT
PlayState
Definition: musicobject.h:183
int m_durationTimes
Definition: musicplayer.h:179
MusicPlaylist * m_playlist
Definition: musicplayer.h:173
The class of the music player.
Definition: musicplayer.h:46
QList< int > TTKIntList
Definition: ttkqtglobal.h:200
SoundCore * m_core
Definition: musicplayer.h:175
qint64 m_duration
Definition: musicplayer.h:178
The namespace of the application object.
Definition: ttkcompat.h:24
QTimer m_timer
Definition: musicplayer.h:176
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:164
TTK::PlayState m_state
Definition: musicplayer.h:174
Enhance
Definition: musicplayer.h:33
QString m_currentMedia
Definition: musicplayer.h:177
The class of the music play list.
Definition: musicplaylist.h:63
The SoundCore class provides a simple interface for audio playback.
Definition: soundcore.h:40
state
Definition: http_parser.c:279