Sayonara Player
RemoteControl.h
1 /* RemoteControl.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef REMOTECONTROL_H
22 #define REMOTECONTROL_H
23 
24 #include "Components/PlayManager/PlayState.h"
25 #include "Utils/Playlist/PlaylistFwd.h"
26 
27 #include <QObject>
28 
29 #include "Utils/Pimpl.h"
30 
31 class QPixmap;
32 
89  public QObject
90 {
91  Q_OBJECT
92  PIMPL(RemoteControl)
93 
94 public:
95  explicit RemoteControl(QObject* parent=nullptr);
96  ~RemoteControl() override;
97 
98  bool isConnected() const;
99 
100 private:
101  void init();
102 
103  void setVolume(int vol);
104  void seekRelative(int posPercent);
105  void seekRelativeMs(int posMs);
106  void seekAbsoluteMs(int posMs);
107  void changeTrack(int idx);
108 
109  void showApi();
110  void requestState();
111 
112  int extractParameterInt(const QByteArray& arr, int commandLength);
113 
114  void insertJsonPlaystate(QJsonObject& o);
115  void writePlaystate();
116 
117  void insertJsonBroadcastInfo(QJsonObject& o);
118  void writeBroadcastInfo();
119 
120  void insertJsonCurrentTrack(QJsonObject& o);
121  void writeCurrentTrack();
122 
123  void insertJsonVolume(QJsonObject& o) const;
124  void writeVolume();
125 
126  void insertJsonCurrentPosition(QJsonObject& o) const;
127  void writeCurrentPosition();
128 
129  void insertJsonPlaylist(QJsonArray& o) const;
130  void writePlaylist();
131 
132  void insertJsonSayonaraIdAndName(QJsonObject& obj) const;
133  void writeSayonaraIdAndName();
134 
135  void searchCover();
136  void jsonCover(QJsonObject& o, const QPixmap& pm) const;
137 
138  void write(const QByteArray& arr);
139 
140  void activeChanged();
141 
142 
143 private slots:
144  void newConnection();
145  void socketDisconnected();
146  void newRequest();
147 
148  void currentPositionChangedMs(MilliSeconds pos);
149  void currentTrackChanged(const MetaData& md);
150  void volumeChanged(int vol);
151  void volumeTimerTimeout();
152  void playstateChanged(PlayState playstate);
153  void activePlaylistChanged(int index);
154  void activePlaylistContentChanged(int index);
155 
156  void coverFound(const QPixmap& pm);
157 
158  void remoteActiveChanged();
159  void remotePortChanged();
160  void broadcastChanged();
161 
162 };
163 
164 
165 
166 #endif // REMOTECONTROL_H
PlayState
PlayState
The PlayState enum.
Definition: PlayState.h:29
MetaData
The MetaData class.
Definition: MetaData.h:47
RemoteControl
Remote control allows to control Sayonara from an external application via network....
Definition: RemoteControl.h:90