2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
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-05-31 22:24:05 +02:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
2010-12-26 18:24:44 +01:00
|
|
|
#include "config.h"
|
2010-11-21 16:13:26 +01:00
|
|
|
#include "core/albumcoverloader.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "core/song.h"
|
2010-04-04 19:50:11 +02:00
|
|
|
#include "engines/engine_fwd.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "playlist/playlistitem.h"
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-05-20 23:21:55 +02:00
|
|
|
class PlaylistManager;
|
2009-12-24 20:16:07 +01:00
|
|
|
class Settings;
|
2010-11-21 16:13:26 +01:00
|
|
|
class MainWindow;
|
2010-12-04 23:27:58 +01:00
|
|
|
|
2010-12-18 18:28:02 +01:00
|
|
|
#ifdef HAVE_LIBLASTFM
|
|
|
|
class LastFMService;
|
|
|
|
#endif
|
|
|
|
|
2010-12-04 23:27:58 +01:00
|
|
|
namespace mpris {
|
|
|
|
class Mpris1;
|
|
|
|
class Mpris2;
|
2010-12-06 00:41:41 +01:00
|
|
|
class ArtLoader;
|
2010-12-04 23:27:58 +01:00
|
|
|
}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-12-26 14:38:35 +01:00
|
|
|
#ifdef HAVE_DBUS
|
2010-11-21 16:13:26 +01:00
|
|
|
# include <QDBusArgument>
|
|
|
|
QDBusArgument& operator<< (QDBusArgument& arg, const QImage& image);
|
|
|
|
const QDBusArgument& operator>> (const QDBusArgument& arg, QImage& image);
|
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:
|
2010-11-21 16:13:26 +01:00
|
|
|
Player(MainWindow* main_window, PlaylistManager* playlists,
|
2010-12-18 18:28:02 +01:00
|
|
|
#ifdef HAVE_LIBLASTFM
|
|
|
|
LastFMService* lastfm,
|
|
|
|
#endif
|
2010-12-26 14:01:35 +01:00
|
|
|
QObject* parent = 0);
|
2010-05-28 21:51:51 +02:00
|
|
|
~Player();
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-02-03 22:48:00 +01:00
|
|
|
void Init();
|
|
|
|
|
2010-12-04 23:27:58 +01:00
|
|
|
EngineBase* engine() const { return engine_.get(); }
|
2010-12-11 14:38:51 +01:00
|
|
|
Engine::State GetState() const { return last_state_; }
|
2009-12-24 20:16:07 +01:00
|
|
|
int GetVolume() const;
|
|
|
|
|
2010-10-16 17:22:14 +02:00
|
|
|
PlaylistItemPtr GetCurrentItem() const { return current_item_; }
|
2010-11-21 16:13:26 +01:00
|
|
|
PlaylistItemPtr GetItemAt(int pos) const;
|
2010-12-04 23:27:58 +01:00
|
|
|
PlaylistManager* playlists() const { return playlists_; }
|
2010-12-06 00:41:41 +01:00
|
|
|
mpris::ArtLoader* ArtLoader() const { return art_loader_; }
|
2010-03-24 21:58:17 +01:00
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
public slots:
|
2010-02-03 17:51:56 +01:00
|
|
|
void ReloadSettings();
|
|
|
|
|
2010-04-30 01:30:24 +02:00
|
|
|
// Manual track change to the specified track
|
|
|
|
void PlayAt(int i, Engine::TrackChangeType change, bool reshuffle);
|
|
|
|
|
|
|
|
// If there's currently a song playing, pause it, otherwise play the track
|
|
|
|
// that was playing last, or the first one on the playlist
|
2009-12-24 20:16:07 +01:00
|
|
|
void PlayPause();
|
2010-04-30 01:30:24 +02:00
|
|
|
|
|
|
|
// Skips this track. Might load more of the current radio station.
|
|
|
|
void Next();
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
void Previous();
|
|
|
|
void SetVolume(int value);
|
2010-12-05 12:39:06 +01:00
|
|
|
void VolumeUp() { SetVolume(GetVolume() + 5); }
|
2010-12-07 19:52:21 +01:00
|
|
|
void VolumeDown() { SetVolume(GetVolume() - 5); }
|
2010-01-15 18:12:47 +01:00
|
|
|
void Seek(int seconds);
|
2010-05-17 13:06:50 +02:00
|
|
|
void SeekForward() { Seek(+5); }
|
|
|
|
void SeekBackward() { Seek(-5); }
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-05-18 22:43:10 +02:00
|
|
|
void HandleSpecialLoad(const PlaylistItem::SpecialLoadResult& result);
|
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 Mute();
|
|
|
|
void Pause();
|
|
|
|
void Stop();
|
|
|
|
void Play();
|
|
|
|
void ShowOSD();
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
signals:
|
|
|
|
void Playing();
|
|
|
|
void Paused();
|
|
|
|
void Stopped();
|
2010-04-19 15:01:57 +02:00
|
|
|
void PlaylistFinished();
|
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-10-17 21:27:31 +02:00
|
|
|
void TrackSkipped(PlaylistItemPtr old_track);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-03-24 21:58:17 +01:00
|
|
|
void ForceShowOSD(Song);
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
private slots:
|
|
|
|
void EngineStateChanged(Engine::State);
|
2010-02-03 23:20:31 +01:00
|
|
|
void EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle);
|
2010-04-21 15:55:30 +02:00
|
|
|
void TrackAboutToEnd();
|
2010-04-30 01:30:24 +02:00
|
|
|
void TrackEnded();
|
|
|
|
// Play the next item on the playlist - disregarding radio stations like
|
|
|
|
// last.fm that might have more tracks.
|
|
|
|
void NextItem(Engine::TrackChangeType change);
|
|
|
|
|
|
|
|
void NextInternal(Engine::TrackChangeType);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
private:
|
2010-12-06 00:41:41 +01:00
|
|
|
mpris::ArtLoader* art_loader_;
|
|
|
|
|
2010-12-04 23:27:58 +01:00
|
|
|
mpris::Mpris1* mpris1_;
|
|
|
|
mpris::Mpris2* mpris2_;
|
2010-03-24 21:58:17 +01:00
|
|
|
|
2010-05-20 23:21:55 +02:00
|
|
|
PlaylistManager* playlists_;
|
2010-12-18 18:28:02 +01:00
|
|
|
#ifdef HAVE_LIBLASTFM
|
2009-12-29 20:22:02 +01:00
|
|
|
LastFMService* lastfm_;
|
2010-12-18 18:28:02 +01:00
|
|
|
#endif
|
2009-12-24 20:16:07 +01:00
|
|
|
QSettings settings_;
|
|
|
|
|
2010-10-16 17:22:14 +02:00
|
|
|
PlaylistItemPtr current_item_;
|
2010-02-03 15:21:53 +01:00
|
|
|
|
2010-05-31 22:24:05 +02:00
|
|
|
boost::scoped_ptr<EngineBase> engine_;
|
2010-04-12 03:59:21 +02:00
|
|
|
Engine::TrackChangeType stream_change_type_;
|
2010-12-11 14:38:51 +01:00
|
|
|
Engine::State last_state_;
|
2010-05-18 22:43:10 +02:00
|
|
|
|
|
|
|
QUrl loading_async_;
|
2010-06-14 22:00:17 +02:00
|
|
|
|
2010-07-14 00:22:04 +02:00
|
|
|
int volume_before_mute_;
|
2009-12-24 20:16:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLAYER_H
|