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 
104 
105  void sigCurrentMetadataChanged();
106 
111  void sigTrackIndexChanged(int idx);
112 
118 
119  void sigBitrateChanged();
120 
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 
237 
238 
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:
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 
PlayManager::currentTrack
const MetaData & currentTrack() const
get current track
PlayManager::sigVolumeChanged
void sigVolumeChanged(int vol)
emitted when volume has changed
PlayState
PlayState
The PlayState enum.
Definition: PlayState.h:29
PlayManager::setMute
void setMute(bool b)
mute/unmute
PlayManager::sigCurrentTrackChanged
void sigCurrentTrackChanged(const MetaData &md)
track has changed
PlayManager::sigPlaystateChanged
void sigPlaystateChanged(PlayState)
emitted, when PlayState was changed
PlayManager::sigStopped
void sigStopped()
stop was triggered
PlayManager::setCurrentPositionMs
void setCurrentPositionMs(MilliSeconds ms)
set current position of track This method does not seek. Just tells the playmanager where the current...
PlayManager::sigPrevious
void sigPrevious()
previous track was triggered
PlayManager::sigStreamFinished
void sigStreamFinished(const MetaData &old_md)
emitted when a streamed track has finished
PlayManager::sigSeekedAbsoluteMs
void sigSeekedAbsoluteMs(MilliSeconds ms)
absolute seeking was triggered
PlayManager::record
void record(bool b)
request recording (see also sig_record(bool b))
PlayManager::sigBuffering
void sigBuffering(int b)
emitted when currently in buffering state
PlayManager::sigWakeup
void sigWakeup()
This signal is sent when the playstate changed from stopped to play.
PlayManager::error
void error(const QString &message)
Some playback error occured.
PlayManager::setVolume
void setVolume(int vol)
set volume
PlayManager
Global handler for current playback state (Singleton)
Definition: PlayManager.h:35
PlayManager::sigSeekedRelative
void sigSeekedRelative(double percent)
relative seeking was triggered
PlayManager::wakeUp
void wakeUp()
Emit wake up signal after stopping state.
PlayManager::isMuted
bool isMuted() const
query mute status
PlayManager::next
void next()
change to next track
PlayManager::play
void play()
Start playing if there's a track.
PlayManager::previous
void previous()
change to previous track
PlayManager::sigPlaylistFinished
void sigPlaylistFinished()
playlist has finished
PlayManager::setTrackReady
void setTrackReady()
notify, that track is ready for playback
PlayManager::shutdown
void shutdown()
Shutdown the computer.
PlayManager::buffering
void buffering(int progress)
notifiy, that track is in buffering state currently
PlayManager::sigMuteChanged
void sigMuteChanged(bool b)
emitted when mute state has changed
PlayManager::initialPositionMs
MilliSeconds initialPositionMs() const
get position in milliseconds where track will start
PlayManager::volumeUp
void volumeUp()
increase volume by 5
PlayManager::sigTrackIndexChanged
void sigTrackIndexChanged(int idx)
track has changed
PlayManager::pause
void pause()
pause track, if currently playing
PlayManager::stop
void stop()
stop playback
PlayManager::seekRelative
void seekRelative(double percent)
seek relative
PlayManager::toggleMute
void toggleMute()
If already muted, then unmute. If unmuted, then mute it.
PlayManager::sigDurationChangedMs
void sigDurationChangedMs()
duration of track has changed
PlayManager::sigRecording
void sigRecording(bool b)
recording is requested
MetaData
The MetaData class.
Definition: MetaData.h:47
PlayManager::playstate
PlayState playstate() const
get current play state
PlayManager::volume
int volume() const
get current volume
PlayManager::seekAbsoluteMs
void seekAbsoluteMs(MilliSeconds ms)
seek absolute
PlayManager::volumeDown
void volumeDown()
decrease volume by 5
PlayManager::durationMs
MilliSeconds durationMs() const
get duration of track
PlayManager::changeCurrentTrack
void changeCurrentTrack(const MetaData &md, int trackIdx)
change current track
PlayManager::sigSeekedRelativeMs
void sigSeekedRelativeMs(MilliSeconds ms)
relative seeking was triggered
PlayManager::sigPositionChangedMs
void sigPositionChangedMs(MilliSeconds ms)
position in track has changed
PlayManager::sigNext
void sigNext()
next track was triggered
PlayManager::playPause
void playPause()
toggle play/pause
PlayManager::seekRelativeMs
void seekRelativeMs(MilliSeconds ms)
seekRelativeMs
PlayManager::changeCurrentMetadata
void changeCurrentMetadata(const MetaData &md)
change_track
PlayManager::changeDuration
void changeDuration(MilliSeconds ms)
Change the duration. This is usually called when the Engine sends a duration changed signal....
PlayManager::currentPositionMs
MilliSeconds currentPositionMs() const
get current position in milliseconds