not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / dataengines / nowplaying / playerinterface / player.h
blobeb38d86d657bd81dd75c24ea5dde72fe9b327799
1 /*
2 * Copyright 2007 Alex Merry <alex.merry@kdemail.net>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef PLAYER_H
20 #define PLAYER_H
22 #include <QSharedData>
23 #include <KSharedPtr>
24 #include <QString>
25 #include <QPixmap>
27 class PlayerFactory;
29 /**
30 * Interface for getting information from and controlling a
31 * media player
33 class Player : public QSharedData
35 public:
36 typedef KSharedPtr<Player> Ptr;
38 Player(PlayerFactory* factory = 0);
39 virtual ~Player();
40 /**
41 * a pointer to the factory that created this player object
43 PlayerFactory* factory() const;
44 /**
45 * The name of this player
47 QString name() const;
48 /**
49 * Current state of the player
51 enum State {
52 Playing,
53 Paused,
54 Stopped
56 /**
57 * Whether the player is running and accessible
59 virtual bool isRunning() = 0;
60 /**
61 * Current state of the player
63 * Undefined if !running()
65 * See State
67 virtual State state() = 0;
68 /** Artist for current track. May be empty */
69 virtual QString artist();
70 /** Album for current track. May be empty */
71 virtual QString album();
72 /** Title of current track. May be empty */
73 virtual QString title();
74 /**
75 * Track number of current track.
77 * Note that this is the track on a CD or in an album, not
78 * the playlist position
80 * 0 if no track defined, or unknown.
82 virtual int trackNumber();
83 /** Comment for current track. May be empty */
84 virtual QString comment();
85 /** Genre of current track. May be empty */
86 virtual QString genre();
87 /**
88 * Length of current track in seconds.
90 * 0 if unknown.
92 virtual int length();
93 /**
94 * Position of current track in seconds.
96 * 0 if unknown, not defined if Stopped.
98 virtual int position();
99 /**
100 * Current volume
102 * Value should be between 0 and 1
104 * -1 if unknown
106 virtual float volume();
108 * Album artwork
110 * Null (pm.isNull()) if none available
112 virtual QPixmap artwork();
114 // Commands
117 * Play a track
119 virtual bool canPlay();
120 virtual void play();
122 * Pause the currently playing track
124 virtual bool canPause();
125 virtual void pause();
127 * Stop the currently playing track
129 * canStop() should usually be state() != Stopped if
130 * stop() is implemented
132 virtual bool canStop();
133 virtual void stop();
135 * Move to the previous track
137 virtual bool canGoPrevious();
138 virtual void previous();
140 * Move to the next track
142 virtual bool canGoNext();
143 virtual void next();
146 * Set the volume
148 * Must be between 0 and 1
150 virtual bool canSetVolume();
151 virtual void setVolume(qreal volume);
154 * Set the position (in seconds)
156 * Should be <= length()
158 virtual bool canSeek();
159 virtual void seek(int time);
161 protected:
162 void setName(const QString& name);
164 private:
165 QString m_name;
166 PlayerFactory* m_factory;
169 #endif // PLAYER_H