TTKMusicPlayer  4.3.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 - 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 QProcess;
26 
30 class TTK_MODULE_EXPORT MusicCoreMPlayer : public QObject
31 {
32  Q_OBJECT
33 public:
34  enum class Module
35  {
36  Null,
37  Radio,
38  Music,
39  Video,
40  Movie,
41  };
42 
46  explicit MusicCoreMPlayer(QObject *parent = nullptr);
51 
55  void setMedia(Module type, const QString &url, int winId = -1);
56 
60  void setPosition(qint64 pos);
61 
65  void setMuted(bool mute);
69  void setVolume(int value);
73  bool isPlaying() const;
77  inline TTK::PlayState state() const noexcept { return m_playState; }
81  inline Module category() const noexcept { return m_category; }
82 
83 Q_SIGNALS:
87  void positionChanged(qint64 position);
91  void durationChanged(qint64 duration);
95  void mediaChanged(const QString &url);
99  void finished(int code);
100 
101 public Q_SLOTS:
105  void play();
109  void stop();
110 
111 private Q_SLOTS:
115  void dataRecieved();
119  void positionRecieved();
123  void durationRecieved();
127  void standardRecieved();
131  void timeout();
135  void checkTimerout();
136 
137 private:
141  void closeModule();
145  void setRadioMedia(const QString &url);
149  void setMusicMedia(const QString &url);
153  void setVideoMedia(const QString &url, int winId);
157  void setMovieMedia(const QString &url, int winId);
158 
159  QProcess *m_process;
162  QTimer m_timer, m_checkTimer;
163 
164 };
165 
166 #endif // MUSICCOREMPLAYER_H
#define TTK_MODULE_EXPORT
PlayState
Definition: musicobject.h:183
TTK::PlayState m_playState
TTK::PlayState state() const noexcept
Module category() const noexcept
The class of the mplayer core.
Definition: inftrees.h:24
#define const
Definition: zconf.h:233