2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
#ifndef PLAYER_H
|
|
|
|
#define PLAYER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSettings>
|
2010-02-03 22:48:00 +01:00
|
|
|
#include <QFuture>
|
|
|
|
#include <QFutureWatcher>
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
#include "engine_fwd.h"
|
2010-02-03 15:21:53 +01:00
|
|
|
#include "playlistitem.h"
|
|
|
|
#include "song.h"
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
class Playlist;
|
|
|
|
class Settings;
|
2009-12-29 20:22:02 +01:00
|
|
|
class LastFMService;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-03-24 22:46:00 +01:00
|
|
|
struct DBusStatus { // From Amarok.
|
|
|
|
int play; // Playing = 0, Paused = 1, Stopped = 2
|
|
|
|
int random; // Linearly = 0, Randomly = 1
|
|
|
|
int repeat; // Go_To_Next = 0, Repeat_Current = 1
|
|
|
|
int repeat_playlist; // Stop_When_Finished = 0, Never_Give_Up_Playing = 1, Never_Let_You_Down = 42
|
|
|
|
|
|
|
|
enum MprisPlayState {
|
|
|
|
Mpris_Playing = 0,
|
|
|
|
Mpris_Paused = 1,
|
|
|
|
Mpris_Stopped = 2,
|
|
|
|
};
|
2010-03-24 21:58:17 +01:00
|
|
|
};
|
|
|
|
Q_DECLARE_METATYPE(DBusStatus);
|
|
|
|
|
2010-03-24 22:34:32 +01:00
|
|
|
#ifdef Q_WS_X11
|
|
|
|
#include <QDBusArgument>
|
2010-03-24 21:58:17 +01:00
|
|
|
QDBusArgument& operator<< (QDBusArgument& arg, const DBusStatus& status);
|
|
|
|
const QDBusArgument& operator>> (const QDBusArgument& arg, DBusStatus& status);
|
2010-03-24 22:34:32 +01:00
|
|
|
#endif
|
2010-03-24 21:58:17 +01:00
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
class Player : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2009-12-29 20:22:02 +01:00
|
|
|
Player(Playlist* playlist, LastFMService* lastfm, QObject* parent = 0);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-02-03 22:48:00 +01:00
|
|
|
void Init();
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
EngineBase* GetEngine() { return engine_; }
|
|
|
|
Engine::State GetState() const;
|
|
|
|
int GetVolume() const;
|
|
|
|
|
2010-02-03 15:21:53 +01:00
|
|
|
PlaylistItem::Options GetCurrentItemOptions() const { return current_item_options_; }
|
|
|
|
Song GetCurrentItem() const { return current_item_; }
|
2010-03-06 16:33:57 +01:00
|
|
|
|
2010-03-24 21:58:17 +01:00
|
|
|
// MPRIS
|
|
|
|
enum DBusCaps {
|
|
|
|
NONE = 0,
|
|
|
|
CAN_GO_NEXT = 1 << 0,
|
|
|
|
CAN_GO_PREV = 1 << 1,
|
|
|
|
CAN_PAUSE = 1 << 2,
|
|
|
|
CAN_PLAY = 1 << 3,
|
|
|
|
CAN_SEEK = 1 << 4,
|
|
|
|
CAN_PROVIDE_METADATA = 1 << 5,
|
|
|
|
CAN_HAS_TRACKLIST = 1 << 6,
|
|
|
|
};
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
public slots:
|
2010-02-03 17:51:56 +01:00
|
|
|
void ReloadSettings();
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
void PlayAt(int index);
|
|
|
|
void PlayPause();
|
2010-02-04 00:12:21 +01:00
|
|
|
void NextItem();
|
2009-12-24 20:16:07 +01:00
|
|
|
void Previous();
|
|
|
|
void SetVolume(int value);
|
2010-01-15 18:12:47 +01:00
|
|
|
void Seek(int seconds);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2009-12-26 23:59:11 +01:00
|
|
|
void TrackEnded();
|
2009-12-26 22:35:45 +01:00
|
|
|
void StreamReady(const QUrl& original_url, const QUrl& media_url);
|
2010-03-08 00:28:40 +01:00
|
|
|
void CurrentMetadataChanged(const Song& metadata);
|
2009-12-26 22:35:45 +01:00
|
|
|
|
2010-03-24 21:58:17 +01:00
|
|
|
void PlaylistChanged();
|
|
|
|
|
|
|
|
// MPRIS /Player
|
|
|
|
int GetCaps() const;
|
|
|
|
DBusStatus GetStatus() const;
|
|
|
|
QVariantMap GetMetadata() const;
|
|
|
|
void Mute();
|
|
|
|
void Pause();
|
|
|
|
void Stop();
|
|
|
|
void Play();
|
|
|
|
void Next();
|
|
|
|
void Prev();
|
|
|
|
int PositionGet() const;
|
|
|
|
void PositionSet(int);
|
|
|
|
void Repeat(bool);
|
|
|
|
void ShowOSD();
|
|
|
|
void VolumeDown(int);
|
|
|
|
void VolumeUp(int);
|
|
|
|
int VolumeGet() const;
|
|
|
|
void VolumeSet(int);
|
|
|
|
|
|
|
|
// MPRIS /Tracklist
|
|
|
|
int AddTrack(const QString&, bool);
|
|
|
|
void DelTrack(int index);
|
|
|
|
int GetCurrentTrack() const;
|
|
|
|
int GetLength() const;
|
|
|
|
QVariantMap GetMetadata(int) const;
|
|
|
|
void SetLoop(bool enable);
|
|
|
|
void SetRandom(bool enable);
|
|
|
|
|
|
|
|
// Amarok extension.
|
|
|
|
void PlayTrack(int index);
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
signals:
|
2010-02-03 22:48:00 +01:00
|
|
|
void InitFinished();
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
void Playing();
|
|
|
|
void Paused();
|
|
|
|
void Stopped();
|
2010-01-08 17:40:34 +01:00
|
|
|
void VolumeChanged(int volume);
|
2009-12-24 20:16:07 +01:00
|
|
|
void Error(const QString& message);
|
|
|
|
|
2010-03-24 21:58:17 +01:00
|
|
|
void ForceShowOSD(Song);
|
|
|
|
|
|
|
|
// MPRIS
|
|
|
|
// Player
|
|
|
|
void CapsChange(int);
|
|
|
|
void TrackChange(QVariantMap);
|
|
|
|
void StatusChange(DBusStatus);
|
|
|
|
// TrackList
|
|
|
|
void TrackListChange(int i);
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
private slots:
|
2010-02-03 22:48:00 +01:00
|
|
|
void EngineInitFinished();
|
2009-12-24 20:16:07 +01:00
|
|
|
void EngineStateChanged(Engine::State);
|
2010-02-03 23:20:31 +01:00
|
|
|
void EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
private:
|
2010-03-24 21:58:17 +01:00
|
|
|
QVariantMap GetMetadata(const PlaylistItem& item) const;
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
Playlist* playlist_;
|
2009-12-29 20:22:02 +01:00
|
|
|
LastFMService* lastfm_;
|
2009-12-24 20:16:07 +01:00
|
|
|
QSettings settings_;
|
|
|
|
|
2010-02-03 15:21:53 +01:00
|
|
|
PlaylistItem::Options current_item_options_;
|
|
|
|
Song current_item_;
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
EngineBase* engine_;
|
2010-02-03 22:48:00 +01:00
|
|
|
QFuture<bool> init_engine_;
|
|
|
|
QFutureWatcher<bool>* init_engine_watcher_;
|
2009-12-24 20:16:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLAYER_H
|