24
24
#include <boost/scoped_ptr.hpp>
26
27
#include "core/albumcoverloader.h"
27
28
#include "core/song.h"
28
29
#include "engines/engine_fwd.h"
29
30
#include "playlist/playlistitem.h"
31
class PlaylistManager;
33
class PlaylistManagerInterface;
43
# include <QDBusArgument>
44
QDBusArgument& operator<< (QDBusArgument& arg, const QImage& image);
45
const QDBusArgument& operator>> (const QDBusArgument& arg, QImage& image);
48
class Player : public QObject {
52
Player(MainWindow* main_window, PlaylistManager* playlists,
53
LastFMService* lastfm, Engine::Type engine, QObject* parent = 0);
38
class PlayerInterface : public QObject {
42
PlayerInterface(QObject* parent = 0) : QObject(parent) {}
44
virtual EngineBase* engine() const = 0;
45
virtual Engine::State GetState() const = 0;
46
virtual int GetVolume() const = 0;
48
virtual PlaylistItemPtr GetCurrentItem() const = 0;
49
virtual PlaylistItemPtr GetItemAt(int pos) const = 0;
50
virtual PlaylistManagerInterface* playlists() const = 0;
53
virtual void ReloadSettings() = 0;
55
// Manual track change to the specified track
56
virtual void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle) = 0;
58
// If there's currently a song playing, pause it, otherwise play the track
59
// that was playing last, or the first one on the playlist
60
virtual void PlayPause() = 0;
62
// Skips this track. Might load more of the current radio station.
63
virtual void Next() = 0;
65
virtual void Previous() = 0;
66
virtual void SetVolume(int value) = 0;
67
virtual void VolumeUp() = 0;
68
virtual void VolumeDown() = 0;
69
virtual void SeekTo(int seconds) = 0;
70
// Moves the position of the currently playing song five seconds forward.
71
virtual void SeekForward() = 0;
72
// Moves the position of the currently playing song five seconds backwards.
73
virtual void SeekBackward() = 0;
75
virtual void HandleSpecialLoad(const PlaylistItem::SpecialLoadResult& result) = 0;
76
virtual void CurrentMetadataChanged(const Song& metadata) = 0;
78
virtual void Mute() = 0;
79
virtual void Pause() = 0;
80
virtual void Stop() = 0;
81
virtual void Play() = 0;
82
virtual void ShowOSD() = 0;
88
void PlaylistFinished();
89
void VolumeChanged(int volume);
90
void Error(const QString& message);
91
void TrackSkipped(PlaylistItemPtr old_track);
92
// Emitted when there's a manual change to the current's track position.
93
void Seeked(qlonglong microseconds);
95
// Emitted when Player has processed a request to play another song. This contains
96
// the URL of the song and a flag saying whether it was able to play the song.
97
void SongChangeRequestProcessed(const QUrl& url, bool valid);
99
void ForceShowOSD(Song);
102
class Player : public PlayerInterface {
106
Player(PlaylistManagerInterface* playlists, LastFMService* lastfm,
107
QObject* parent = 0);
56
EngineBase* CreateEngine(Engine::Type engine);
59
112
EngineBase* engine() const { return engine_.get(); }
63
116
PlaylistItemPtr GetCurrentItem() const { return current_item_; }
64
117
PlaylistItemPtr GetItemAt(int pos) const;
65
PlaylistManager* playlists() const { return playlists_; }
66
mpris::ArtLoader* ArtLoader() const { return art_loader_; }
118
PlaylistManagerInterface* playlists() const { return playlists_; }
69
121
void ReloadSettings();
71
// Manual track change to the specified track
72
void PlayAt(int i, Engine::TrackChangeType change, bool reshuffle);
74
// If there's currently a song playing, pause it, otherwise play the track
75
// that was playing last, or the first one on the playlist
123
void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle);
78
// Skips this track. Might load more of the current radio station.
82
127
void SetVolume(int value);
83
128
void VolumeUp() { SetVolume(GetVolume() + 5); }
84
129
void VolumeDown() { SetVolume(GetVolume() - 5); }
85
void Seek(int seconds);
86
void SeekForward() { Seek(+5); }
87
void SeekBackward() { Seek(-5); }
130
void SeekTo(int seconds);
89
134
void HandleSpecialLoad(const PlaylistItem::SpecialLoadResult& result);
90
135
void CurrentMetadataChanged(const Song& metadata);
113
147
void TrackEnded();
114
148
// Play the next item on the playlist - disregarding radio stations like
115
149
// last.fm that might have more tracks.
116
void NextItem(Engine::TrackChangeType change);
118
void NextInternal(Engine::TrackChangeType);
150
void NextItem(Engine::TrackChangeFlags change);
152
void NextInternal(Engine::TrackChangeFlags);
154
void ValidSongRequested(const QUrl&);
155
void InvalidSongRequested(const QUrl&);
121
mpris::ArtLoader* art_loader_;
123
mpris::Mpris1* mpris1_;
124
mpris::Mpris2* mpris2_;
126
PlaylistManager* playlists_;
158
PlaylistManagerInterface* playlists_;
127
159
LastFMService* lastfm_;
128
160
QSettings settings_;
130
162
PlaylistItemPtr current_item_;
132
164
boost::scoped_ptr<EngineBase> engine_;
133
Engine::TrackChangeType stream_change_type_;
165
Engine::TrackChangeFlags stream_change_type_;
134
166
Engine::State last_state_;
136
168
QUrl loading_async_;