Sayonara Player
RemoteControl.h
1 /* RemoteControl.h */
2 
3 /* Copyright (C) 2011-2019 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 
87  public QObject
88 {
89  Q_OBJECT
90  PIMPL(RemoteControl)
91 
92 public:
93  explicit RemoteControl(QObject *parent=nullptr);
94  ~RemoteControl() override;
95 
96  bool is_connected() const;
97 
98 private slots:
99  void new_connection();
100  void socket_disconnected();
101  void new_request();
102 
103  void pos_changed_ms(MilliSeconds pos);
104  void track_changed(const MetaData& md);
105  void volume_changed(int vol);
106  void playstate_changed(PlayState playstate);
107  void active_playlist_changed(int index);
108  void active_playlist_content_changed(int index);
109 
110  void cover_found(const QPixmap& pm);
111 
112  void _sl_active_changed();
113  void _sl_port_changed();
114  void _sl_broadcast_changed();
115 
116 
117 private:
118  void init();
119 
120  void set_volume(int vol);
121  void seek_rel(int pos_percent);
122  void seek_rel_ms(int pos_ms);
123  void change_track(int idx);
124 
125  void show_api();
126  void request_state();
127 
128  int extract_parameter_int(const QByteArray& arr, int cmd_len);
129 
130  void json_playstate(QJsonObject& o);
131  void write_playstate();
132 
133  void json_broadcast_info(QJsonObject& o);
134  void write_broadcast_info();
135 
136  void json_current_track(QJsonObject& o);
137  void write_current_track();
138 
139  void json_volume(QJsonObject& o) const;
140  void write_volume();
141 
142  void json_current_position(QJsonObject& o) const;
143  void write_current_position();
144 
145  void json_playlist(QJsonArray& o) const;
146  void write_playlist();
147 
148  void search_cover();
149  void json_cover(QJsonObject& o, const QPixmap& pm) const;
150 
151  void write(const QByteArray& arr);
152 
153  void active_changed();
154 };
155 
156 
157 
158 #endif // REMOTECONTROL_H
PlayState
The PlayState enum.
Definition: PlayState.h:28
The MetaData class.
Definition: MetaData.h:44
Remote control allows to control Sayonara from an external application via network....
Definition: RemoteControl.h:86