TTKMusicPlayer  4.1.3.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 - 2025 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  Movie,
42  };
43 
47  explicit MusicCoreMPlayer(QObject *parent = nullptr);
52 
56  void setMedia(Module type, const QString &url, int winId = -1);
57 
61  void setPosition(qint64 pos);
62 
66  void setMuted(bool mute);
70  void setVolume(int value);
74  bool isPlaying() const;
78  inline TTK::PlayState state() const { return m_playState; }
82  inline Module category() const { return m_category; }
83 
84 Q_SIGNALS:
88  void positionChanged(qint64 position);
92  void durationChanged(qint64 duration);
96  void mediaChanged(const QString &url);
100  void finished(int code);
101 
102 public Q_SLOTS:
106  void play();
110  void stop();
111 
112 private Q_SLOTS:
116  void dataRecieved();
120  void positionRecieved();
124  void durationRecieved();
128  void standardRecieved();
132  void timeout();
136  void checkTimerout();
137 
138 private:
142  void closeModule();
146  void setRadioMedia(const QString &url);
150  void setMusicMedia(const QString &url);
154  void setVideoMedia(const QString &url, int winId);
158  void setMovieMedia(const QString &url, int winId);
159 
160  QProcess *m_process;
163  QTimer m_timer, m_checkTimer;
164 
165 };
166 
167 #endif // MUSICCOREMPLAYER_H
#define TTK_MODULE_EXPORT
PlayState
Definition: musicobject.h:166
TTK::PlayState state() const
Module category() const
TTK::PlayState m_playState
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:168
The class of the mplayer core.
Definition: inftrees.h:24