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. Various commands are implemented. Sayonara also delivers information about state changes,The current implemented commands are: play start playing pause pause playing prev previous song next next song playpause toggle play/pause stop stop playing volup increase volume voldown decrease volume setvol <int> change volume pl fetch the active playlist curSong fetch the current song index seekrel <int> seek within song in percent seekrelms <int> seek within song in relative to current position in seconds chtrk <int> change track state request state: every answer except playlists are returned Answers are sent in JSON format. Each answer is terminated with 10 bytes long ENDMESSAGE. The list of attributes is: volume<int> current volume value between 0 and 100 Current track track-title<string> current track title track-artist<string> current track artist track-album<string> current track album track-total-time<int> current track total time in seconds track-current-position<int> current track position in seconds Broadcasting broadcast-active<bool> is broadcast active? broadcast-port<int> port where broadcasts can be received from Cover cover-data<string> Base64 encoded JPG file cover-width<int> width of cover pixmap cover-height<int> height of cover pixmap playstate<string> one of the values "playing", "paused" or "stopped" Playlist playlist-current-index<int> current playing track index playlist<array> array of tracks pl-track-title<int> title of track pl-track-album<string> album of track pl-track-artist<string> artist of track pl-track-total-time<int> length of track in seconds .
Definition: RemoteControl.h:86