Merge branch 'master' of http://git.fredemmott.co.uk/repo/yanihp
[jkt-jerboa.git] / include / PlayerInterface.h
blob01dd5d3b6e629759b4bf99711792aad254533642
1 /* LICENSE NOTICE
2 This file is part of Jerboa.
4 Jerboa is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option), version 3 of the license.
9 Jerboa is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Jerboa. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef _JERBOA_PLAYER_INTERFACE_H
18 #define _JERBOA_PLAYER_INTERFACE_H
20 #include "Types.h"
21 #include "TrackData.h"
23 #include <QObject>
24 #include <QWidget>
26 namespace Jerboa
28 class PlaylistInterface;
30 /** Provides an interface for plugins to interact with the player.
31 * All interaction with the player is through this abstract class.
33 class PlayerInterface : public QObject
35 Q_OBJECT;
36 public:
37 /** The current volume of the player.
38 * Between 0 and 1.
39 * \see setVolume
41 virtual qreal volume() const = 0;
42 /** The current volume of the player, in decibels.
43 * \see setVolumeDecibel
45 virtual qreal volumeDecibel() const = 0;
47 /** The position in the current track.
48 * Measured in milliseconds.
49 * \see setPosition
51 virtual quint64 position() const = 0;
53 /// An interface to the playlist.
54 virtual PlaylistInterface* playlist() const = 0;
55 public slots:
56 virtual void play() = 0;
57 virtual void pause() = 0;
58 virtual void stop() = 0;
59 virtual void skipNext() = 0;
60 virtual void skipPrevious() = 0;
62 /** Seeks to a position in the current track.
63 * \arg position is the time into the track to seek to, in milliseconds.
64 * \see position
66 virtual void setPosition(quint64 position) = 0;
68 /** Set the volume of the player.
69 * \arg v is the level to set to, between 0 and 1.
70 * \see volume
72 virtual void setVolume(qreal v) = 0;
74 /** Set the volume of the player, in decibels.
75 * \see setVolumeDecibels
77 virtual void setVolumeDecibel(qreal) = 0;
79 /// Set the looping mode of the player.
80 virtual void setLoopMode(LoopMode) = 0;
81 /// Set the shuffle mode of the player.
82 virtual void setShuffleMode(ShuffleMode) = 0;
84 /** The main window of the player.
85 * Do not cast this to a PlayerWindow object; the only supported operations
86 * on the result of this call are those inherited from QWidget.
88 virtual QWidget* mainWindow() const = 0;
89 signals:
90 void loopModeChanged(LoopMode);
91 void shuffleModeChanged(ShuffleMode);
93 /** This signal is emitted when the actions the player is able to perform change.
94 * \arg available contains a bitwise OR of \ref Action flags.
96 void availableActionsChanged(Actions available);
98 /** This signal is emitted when the current track changes.
99 * Notably, it is emitted before playback actually starts,
100 * in between the two tracks, so could be useful to implement
101 * replaygain in a plugin.
103 * \arg newTrack is the \ref TrackData for the new track.
105 void trackChanged(const TrackData& newTrack);
107 /** This signal is emitted when playback of a new track starts.
108 * \arg track is the \ref TrackData for the new track.
109 * \arg length is the length of the track, in milliseconds.
111 void playbackStarted(const TrackData& track, quint64 length);
113 void playbackPaused();
114 void playbackStopped();
116 * \see volume
117 * \see volumeDecibel
119 void volumeChanged(qreal fraction, qreal db);
120 protected:
121 PlayerInterface(QObject* parent);
124 #endif