Sayonara Player
PlayManager.h
1 /* PlayManager.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 PLAY_MANAGER_H
22 #define PLAY_MANAGER_H
23 
24 #include <QObject>
25 #include "PlayState.h"
26 #include "Utils/Singleton.h"
27 #include "Utils/Pimpl.h"
28 
33 class PlayManager :
34  public QObject
35 {
36  Q_OBJECT
37 
38  SINGLETON_QOBJECT(PlayManager)
39  PIMPL(PlayManager)
40 
41 signals:
42 
47  void sigStreamFinished(const MetaData& old_md);
48 
53 
57  void sigNext();
58 
63  void sigWakeup();
64 
68  void sigPrevious();
69 
73  void sigStopped();
74 
79  void sigSeekedRelative(double percent);
80 
85  void sigSeekedRelativeMs(MilliSeconds ms);
86 
91  void sigSeekedAbsoluteMs(MilliSeconds ms);
92 
97  void sigPositionChangedMs(MilliSeconds ms);
98 
103  void sigCurrentTrackChanged(const MetaData& md);
104 
105  void sigCurrentMetadataChanged();
106 
111  void sigTrackIndexChanged(int idx);
112 
117  void sigDurationChangedMs();
118 
119  void sigBitrateChanged();
120 
124  void sigPlaylistFinished();
125 
132  void sigRecording(bool b);
133 
138  void sigBuffering(int b);
139 
144  void sigVolumeChanged(int vol);
145 
146 
151  void sigMuteChanged(bool b);
152 
153  void sigError(const QString& message);
154 
155 
156 public slots:
160  void play();
161 
165  void wakeUp();
166 
170  void playPause();
171 
175  void pause();
176 
180  void previous();
181 
185  void next();
186 
190  void stop();
191 
198  void record(bool b);
199 
204  void seekRelative(double percent);
205 
210  void seekAbsoluteMs(MilliSeconds ms);
211 
216  void seekRelativeMs(MilliSeconds ms);
217 
224  void setCurrentPositionMs(MilliSeconds ms);
225 
230  void changeCurrentTrack(const MetaData& md, int trackIdx);
231 
236  void changeCurrentMetadata(const MetaData& md);
237 
238 
242  void setTrackReady();
243  void setTrackFinished();
244 
249  void buffering(int progress);
250 
254  void volumeUp();
255 
259  void volumeDown();
260 
265  void setVolume(int vol);
266 
271  void setMute(bool b);
272 
276  void toggleMute();
277 
278 
285  void changeDuration(MilliSeconds ms);
286 
287  void changeBitrate(Bitrate br);
288 
293  void error(const QString& message);
294 
295 public:
300  PlayState playstate() const;
301 
306  MilliSeconds currentPositionMs() const;
307 
308  MilliSeconds currentTrackPlaytimeMs() const;
309 
314  MilliSeconds initialPositionMs() const;
315 
320  MilliSeconds durationMs() const;
321 
322 
323  Bitrate bitrate() const;
324 
329  const MetaData& currentTrack() const;
330 
335  int volume() const;
336 
337 
342  bool isMuted() const;
343 
344 
348  void shutdown();
349 
350 private slots:
351  void trackMetadataChanged();
352  void tracksDeleted();
353 };
354 
355 #endif
356 
357 
void sigPositionChangedMs(MilliSeconds ms)
position in track has changed
void sigStreamFinished(const MetaData &old_md)
emitted when a streamed track has finished
void sigBuffering(int b)
emitted when currently in buffering state
void sigDurationChangedMs()
duration of track has changed
void shutdown()
Shutdown the computer.
bool isMuted() const
query mute status
void play()
Start playing if there's a track.
void sigSeekedRelative(double percent)
relative seeking was triggered
void sigPlaylistFinished()
playlist has finished
void sigNext()
next track was triggered
PlayState
The PlayState enum.
Definition: PlayState.h:28
void volumeDown()
decrease volume by 5
The MetaData class.
Definition: MetaData.h:45
void seekRelativeMs(MilliSeconds ms)
seekRelativeMs
void sigRecording(bool b)
recording is requested
MilliSeconds initialPositionMs() const
get position in milliseconds where track will start
void volumeUp()
increase volume by 5
void changeDuration(MilliSeconds ms)
Change the duration. This is usually called when the Engine sends a duration changed signal....
void seekAbsoluteMs(MilliSeconds ms)
seek absolute
Global handler for current playback state (Singleton)
Definition: PlayManager.h:33
void record(bool b)
request recording (see also sig_record(bool b))
void sigSeekedAbsoluteMs(MilliSeconds ms)
absolute seeking was triggered
void toggleMute()
If already muted, then unmute. If unmuted, then mute it.
PlayState playstate() const
get current play state
void sigStopped()
stop was triggered
void sigWakeup()
This signal is sent when the playstate changed from stopped to play.
void error(const QString &message)
Some playback error occured.
MilliSeconds durationMs() const
get duration of track
void sigPrevious()
previous track was triggered
void wakeUp()
Emit wake up signal after stopping state.
void buffering(int progress)
notifiy, that track is in buffering state currently
void playPause()
toggle play/pause
void next()
change to next track
void changeCurrentTrack(const MetaData &md, int trackIdx)
change current track
void sigSeekedRelativeMs(MilliSeconds ms)
relative seeking was triggered
void setTrackReady()
notify, that track is ready for playback
MilliSeconds currentPositionMs() const
get current position in milliseconds
void sigPlaystateChanged(PlayState)
emitted, when PlayState was changed
void setVolume(int vol)
set volume
void sigMuteChanged(bool b)
emitted when mute state has changed
const MetaData & currentTrack() const
get current track
void sigVolumeChanged(int vol)
emitted when volume has changed
void changeCurrentMetadata(const MetaData &md)
change_track
void setCurrentPositionMs(MilliSeconds ms)
set current position of track This method does not seek. Just tells the playmanager where the current...
void setMute(bool b)
mute/unmute
void pause()
pause track, if currently playing
void sigCurrentTrackChanged(const MetaData &md)
track has changed
void previous()
change to previous track
void sigTrackIndexChanged(int idx)
track has changed
void stop()
stop playback
void seekRelative(double percent)
seek relative
int volume() const
get current volume