TTKMusicPlayer  3.7.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 - 2024 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 class TTK_MODULE_EXPORT MusicPlayer : public QObject
32 {
33  Q_OBJECT
35 public:
36  enum class Enhance
37  {
38  Off,
39  M3D,
40  NICAM,
41  Subwoofer,
42  Vocal
43  };
44 
48  explicit MusicPlayer(QObject *parent = nullptr);
52  ~MusicPlayer();
53 
57  bool isPlaying() const;
61  TTK::PlayState state() const;
62 
66  void setPlaylist(MusicPlaylist *playlist);
67 
71  qint64 duration() const;
75  qint64 position() const;
79  void setPosition(qint64 position);
80 
84  int volume() const;
88  void setVolume(int volume);
92  bool isMuted() const;
96  void setMuted(bool muted);
97 
101  void setEnhanced(Enhance type);
105  Enhance enhanced() const;
106 
107 Q_SIGNALS:
111  void stateChanged(TTK::PlayState state);
115  void durationChanged(qint64 duration);
119  void positionChanged(qint64 position);
120 
121 public Q_SLOTS:
125  void play();
129  void pause();
133  void stop();
137  void setEqualizerEffect(const TTKIntList &hz);
141  void setEnabledEffect(bool enabled);
145  void setEqualizerConfig();
146 
147 private Q_SLOTS:
151  void update();
155  void generateDuration();
156 
157 private:
161  void setStopState();
165  void setCurrentPlayState(TTK::PlayState state);
166 
170  QTimer m_timer;
171  QString m_currentMedia;
173  qint64 m_duration;
174 
178 
179 };
180 
181 #endif // MUSICPLAYER_H
#define TTK_MODULE_EXPORT
PlayState
Definition: musicobject.h:164
Enhance m_enhance
Definition: musicplayer.h:172
float m_posOnCircle
Definition: musicplayer.h:177
int m_durationTimes
Definition: musicplayer.h:175
MusicPlaylist * m_playlist
Definition: musicplayer.h:167
The class of the music player.
Definition: musicplayer.h:31
QList< int > TTKIntList
Definition: ttkqtglobal.h:188
SoundCore * m_core
Definition: musicplayer.h:169
qint64 m_duration
Definition: musicplayer.h:173
QTimer m_timer
Definition: musicplayer.h:170
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:152
int m_volumeMusic3D
Definition: musicplayer.h:176
TTK::PlayState m_state
Definition: musicplayer.h:168
QString m_currentMedia
Definition: musicplayer.h:171
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