TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musiccoremplayer.h
Go to the documentation of this file.
1 #ifndef MUSICCOREMPLAYER_H
2 #define MUSICCOREMPLAYER_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 QProcess;
26 
30 class TTK_MODULE_EXPORT MusicCoreMPlayer : public QObject
31 {
32  Q_OBJECT
34 public:
35  enum class Module
36  {
37  Null,
38  Radio,
39  Music,
40  Video
41  };
42 
46  explicit MusicCoreMPlayer(QObject *parent = nullptr);
51 
55  void setMedia(Module type, const QString &data, int winId = -1);
56 
60  void setPosition(qint64 pos);
64  void setLeftVolume();
68  void setRightVolume();
72  void setMultiVoice(int number);
73 
77  void setMute(bool mute);
81  void setVolume(int value);
85  bool isPlaying() const;
89  inline TTK::PlayState state() const { return m_playState; }
93  inline Module category() const { return m_category; }
94 
95 Q_SIGNALS:
99  void positionChanged(qint64 position);
103  void durationChanged(qint64 duration);
107  void mediaChanged(const QString &data);
111  void finished(int code);
112 
113 public Q_SLOTS:
117  void play();
121  void stop();
122 
123 private Q_SLOTS:
127  void dataRecieve();
131  void positionRecieve();
135  void durationRecieve();
139  void standardRecieve();
143  void timeout();
147  void checkTimerout();
148 
149 private:
153  void closeModule();
157  void setRadioMedia(const QString &data);
161  void setMusicMedia(const QString &data);
165  void setVideoMedia(const QString &data, int winId);
166 
167  QProcess *m_process;
170  QTimer m_timer, m_checkTimer;
171 
172 };
173 
174 #endif // MUSICCOREMPLAYER_H
#define TTK_MODULE_EXPORT
PlayState
Definition: musicobject.h:164
TTK::PlayState state() const
Module category() const
TTK::PlayState m_playState
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:152
The class of the mplayer core.
Definition: inftrees.h:24