~ari-tczew/ubuntu/natty/clementine/lp-747113

« back to all changes in this revision

Viewing changes to src/core/player.h

  • Committer: Artur Rona
  • Date: 2011-04-04 20:05:33 UTC
  • Revision ID: ari-tczew@ubuntu.com-20110404200533-6aclzasj5pp8t1hq
* New upstream release. (LP: #747113)
* Drop all patches, have been applied upstream.
* Update debian/copyright.
* Refresh description in debian/control in order to avoid lintian error.
* Bump debhelper to 8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <boost/scoped_ptr.hpp>
25
25
 
 
26
#include "config.h"
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"
30
31
 
31
 
class PlaylistManager;
 
32
class LastFMService;
 
33
class PlaylistManagerInterface;
32
34
class Settings;
33
 
class LastFMService;
34
35
class MainWindow;
35
36
 
36
 
namespace mpris {
37
 
  class Mpris1;
38
 
  class Mpris2;
39
 
  class ArtLoader;
40
 
}
41
 
 
42
 
#ifdef Q_WS_X11
43
 
# include <QDBusArgument>
44
 
  QDBusArgument& operator<< (QDBusArgument& arg, const QImage& image);
45
 
  const QDBusArgument& operator>> (const QDBusArgument& arg, QImage& image);
46
 
#endif
47
 
 
48
 
class Player : public QObject {
49
 
  Q_OBJECT
50
 
 
51
 
 public:
52
 
  Player(MainWindow* main_window, PlaylistManager* playlists,
53
 
         LastFMService* lastfm, Engine::Type engine, QObject* parent = 0);
 
37
 
 
38
class PlayerInterface : public QObject {
 
39
  Q_OBJECT
 
40
 
 
41
public:
 
42
  PlayerInterface(QObject* parent = 0) : QObject(parent) {}
 
43
 
 
44
  virtual EngineBase* engine() const = 0;
 
45
  virtual Engine::State GetState() const = 0;
 
46
  virtual int GetVolume() const = 0;
 
47
 
 
48
  virtual PlaylistItemPtr GetCurrentItem() const = 0;
 
49
  virtual PlaylistItemPtr GetItemAt(int pos) const = 0;
 
50
  virtual PlaylistManagerInterface* playlists() const = 0;
 
51
 
 
52
public slots:
 
53
  virtual void ReloadSettings() = 0;
 
54
 
 
55
  // Manual track change to the specified track
 
56
  virtual void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle) = 0;
 
57
 
 
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;
 
61
 
 
62
  // Skips this track.  Might load more of the current radio station.
 
63
  virtual void Next() = 0;
 
64
 
 
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;
 
74
 
 
75
  virtual void HandleSpecialLoad(const PlaylistItem::SpecialLoadResult& result) = 0;
 
76
  virtual void CurrentMetadataChanged(const Song& metadata) = 0;
 
77
 
 
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;
 
83
 
 
84
signals:
 
85
  void Playing();
 
86
  void Paused();
 
87
  void Stopped();
 
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);
 
94
 
 
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);
 
98
 
 
99
  void ForceShowOSD(Song);
 
100
};
 
101
 
 
102
class Player : public PlayerInterface {
 
103
  Q_OBJECT
 
104
 
 
105
public:
 
106
  Player(PlaylistManagerInterface* playlists, LastFMService* lastfm,
 
107
         QObject* parent = 0);
54
108
  ~Player();
55
109
 
56
 
  EngineBase* CreateEngine(Engine::Type engine);
57
110
  void Init();
58
111
 
59
112
  EngineBase* engine() const { return engine_.get(); }
62
115
 
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_; }
67
119
 
68
 
 public slots:
 
120
public slots:
69
121
  void ReloadSettings();
70
122
 
71
 
  // Manual track change to the specified track
72
 
  void PlayAt(int i, Engine::TrackChangeType change, bool reshuffle);
73
 
 
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);
76
124
  void PlayPause();
77
 
 
78
 
  // Skips this track.  Might load more of the current radio station.
79
125
  void Next();
80
 
 
81
126
  void Previous();
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);
 
131
  void SeekForward();
 
132
  void SeekBackward();
88
133
 
89
134
  void HandleSpecialLoad(const PlaylistItem::SpecialLoadResult& result);
90
135
  void CurrentMetadataChanged(const Song& metadata);
95
140
  void Play();
96
141
  void ShowOSD();
97
142
 
98
 
 signals:
99
 
  void Playing();
100
 
  void Paused();
101
 
  void Stopped();
102
 
  void PlaylistFinished();
103
 
  void VolumeChanged(int volume);
104
 
  void Error(const QString& message);
105
 
  void TrackSkipped(PlaylistItemPtr old_track);
106
 
 
107
 
  void ForceShowOSD(Song);
108
 
 
109
143
 private slots:
110
144
  void EngineStateChanged(Engine::State);
111
145
  void EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle);
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);
117
 
 
118
 
  void NextInternal(Engine::TrackChangeType);
 
150
  void NextItem(Engine::TrackChangeFlags change);
 
151
 
 
152
  void NextInternal(Engine::TrackChangeFlags);
 
153
 
 
154
  void ValidSongRequested(const QUrl&);
 
155
  void InvalidSongRequested(const QUrl&);
119
156
 
120
157
 private:
121
 
  mpris::ArtLoader* art_loader_;
122
 
 
123
 
  mpris::Mpris1* mpris1_;
124
 
  mpris::Mpris2* mpris2_;
125
 
 
126
 
  PlaylistManager* playlists_;
 
158
  PlaylistManagerInterface* playlists_;
127
159
  LastFMService* lastfm_;
128
160
  QSettings settings_;
129
161
 
130
162
  PlaylistItemPtr current_item_;
131
163
 
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_;
135
167
 
136
168
  QUrl loading_async_;