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
21 #include "TrackData.h"
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
37 /** The current volume of the player.
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.
51 virtual quint64
position() const = 0;
53 /// An interface to the playlist.
54 virtual PlaylistInterface
* playlist() const = 0;
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.
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.
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;
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();
119 void volumeChanged(qreal fraction
, qreal db
);
121 PlayerInterface(QObject
* parent
);