Sayonara Player
RemoteControl.h
1 /* RemoteControl.h */
2 
3 /* Copyright (C) 2011-2017 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/Settings/SayonaraClass.h"
26 #include "Utils/Playlist/PlaylistFwd.h"
27 
28 #include <QObject>
29 
30 #include "Utils/Pimpl.h"
31 
32 class MetaData;
33 class QByteArray;
34 
77  public QObject,
78  public SayonaraClass
79 {
80  Q_OBJECT
81  PIMPL(RemoteControl)
82 
83 public:
84  explicit RemoteControl(QObject *parent=nullptr);
85  virtual ~RemoteControl();
86 
87  bool is_connected() const;
88 
89 private slots:
90  void new_connection();
91  void socket_disconnected();
92  void new_request();
93 
94  void pos_changed_ms(const uint64_t pos);
95  void track_changed(const MetaData& md);
96  void volume_changed(int vol);
97  void playstate_changed(PlayState playstate);
98  void playlist_changed(PlaylistConstPtr pl);
99 
100  void _sl_active_changed();
101  void _sl_port_changed();
102  void _sl_broadcast_changed();
103 
104 
105 private:
106 
107  void init();
108 
109  void set_volume(int vol);
110  void seek_rel(int pos_percent);
111  void seek_rel_ms(int pos_ms);
112  void change_track(int idx);
113 
114  void show_api();
115  void request_state();
116 
117  int extract_parameter_int(const QByteArray& arr, int cmd_len);
118 
119  void write_playstate();
120  void write_broadcast_info();
121  void write_cur_track();
122  void write_volume();
123  void write_cur_pos();
124  void write_playlist();
125 
126  void write_cover();
127  void write_cover(const MetaData& md);
128 
129  void write(const QByteArray& arr);
130 };
131 
132 #endif // REMOTECONTROL_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
PlayState
The PlayState enum.
Definition: PlayState.h:28
The MetaData class.
Definition: MetaData.h:48
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: .
Definition: RemoteControl.h:76
std::shared_ptr< const Playlist::Base > PlaylistConstPtr
PlaylistConstPtr read only Playlist Pointer.
Definition: PlaylistFwd.h:45