Clementine-audio-player-Mac.../src/core/player.h

132 lines
3.4 KiB
C
Raw Normal View History

/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
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"
#include "core/albumcoverloader.h"
#include "core/song.h"
#include "engines/engine_fwd.h"
#include "playlist/playlistitem.h"
2009-12-24 20:16:07 +01:00
class PlaylistManager;
2009-12-24 20:16:07 +01:00
class Settings;
class MainWindow;
#ifdef HAVE_LIBLASTFM
class LastFMService;
#endif
2009-12-24 20:16:07 +01:00
class Player : public QObject {
Q_OBJECT
public:
Player(PlaylistManager* playlists,
#ifdef HAVE_LIBLASTFM
LastFMService* lastfm,
#endif
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();
EngineBase* engine() const { return engine_.get(); }
Engine::State GetState() const { return last_state_; }
2009-12-24 20:16:07 +01:00
int GetVolume() const;
PlaylistItemPtr GetCurrentItem() const { return current_item_; }
PlaylistItemPtr GetItemAt(int pos) const;
PlaylistManager* playlists() const { return playlists_; }
2009-12-24 20:16:07 +01:00
public slots:
void ReloadSettings();
// 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();
// 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);
void VolumeUp() { SetVolume(GetVolume() + 5); }
void VolumeDown() { SetVolume(GetVolume() - 5); }
2010-01-15 18:12:47 +01:00
void Seek(int seconds);
void SeekForward() { Seek(+5); }
void SeekBackward() { Seek(-5); }
2009-12-24 20:16:07 +01:00
void HandleSpecialLoad(const PlaylistItem::SpecialLoadResult& result);
void CurrentMetadataChanged(const Song& metadata);
2009-12-26 22:35:45 +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();
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);
void TrackSkipped(PlaylistItemPtr old_track);
2009-12-24 20:16:07 +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();
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:
PlaylistManager* playlists_;
#ifdef HAVE_LIBLASTFM
2009-12-29 20:22:02 +01:00
LastFMService* lastfm_;
#endif
2009-12-24 20:16:07 +01:00
QSettings settings_;
PlaylistItemPtr current_item_;
2010-05-31 22:24:05 +02:00
boost::scoped_ptr<EngineBase> engine_;
Engine::TrackChangeType stream_change_type_;
Engine::State last_state_;
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