Version bump
[someplayer] / src / player / player.h
1 /*
2  * SomePlayer - An alternate music player for Maemo 5
3  * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef PLAYER_H
21 #define PLAYER_H
22
23 #include <QObject>
24 #include "../someplayer.h"
25 #include "../track.h"
26 #include "../trackmetainformation.h"
27 #include "../playlist.h"
28 #include "abstractplayer.h"
29 #include <phonon/MediaObject>
30 #include <phonon/AudioOutput>
31 #include <phonon/Effect>
32 #include <phonon/Path>
33 #include <QStack>
34 #include <QQueue>
35
36 // represents player
37
38 using SomePlayer::DataObjects::Track;
39 using SomePlayer::DataObjects::TrackMetadata;
40 using SomePlayer::DataObjects::Playlist;
41 using SomePlayer::DataObjects::LastPlayed;
42 using SomePlayer::Storage::Config;
43
44 namespace SomePlayer {
45         namespace Playback {
46
47                 class Randomizer {
48                 public:
49                         void setPlaylist(QList<int>);
50                         int next();
51                         void removeId(int);
52                 private:
53                         QList<int> _playlist;
54                         QList<int> _rand;
55                         void _shuffle();
56                         int _last;
57                 };
58
59                 class Player : public AbstractPlayer
60                 {
61                         Q_OBJECT
62                 public:
63                         explicit Player(QObject *parent = 0);
64                         ~Player();
65
66                         virtual bool random() {return _random;}
67                         virtual RepeatRule repeat() {return _repeat;}
68                         virtual bool equalizerEnabled() {return _equalizer_enabled;}
69                         virtual bool equalizerAvailable() {return _equalizer != NULL;}
70                         virtual Track current();
71                         virtual void setAwaitingSeek(int pos) {_awaiting_seek_pos = pos; _awaiting_seek = true;}
72
73                 public slots:
74                         void setTrackId(int id);
75                         void enqueue(int id); // refactor
76                         void toggle();
77                         void play();
78                         void pause();
79                         void playIfPaused();
80                         void stop();
81                         void next();
82                         void prev();
83                         void setPlaylist(Playlist);
84                         void toggleRandom();
85                         void toggleRepeat();
86                         void seek(int);
87                         void enableEqualizer();
88                         void disableEqualizer();
89                         void setEqualizerValue(int band, double value);
90                         void equalizerValue(int band, double *);
91                         QString artist();
92                         QString album();
93                         QString title();
94                         PlayerState state() {return _state;}
95                         QString stateText();
96                         QString albumart() {return _albumart;}
97                         void setAlbumart(QString albumart) {_albumart = albumart;}
98                 private slots:
99                         void _stateChanged(Phonon::State, Phonon::State);
100                         void _tick(qint64);
101                 private:
102                         Track _track; // current track
103                         bool _random;
104                         RepeatRule _repeat;
105                         bool _equalizer_enabled;
106                         QList<Track> _history;
107                         QList<Track> _queue;
108                         Playlist _playlist;
109                         Phonon::MediaObject *_player;
110                         Phonon::AudioOutput *_output;
111                         Phonon::Path _path;
112                         Phonon::Effect *_equalizer;
113                         PlayerState _state;
114                         Config _config;
115                         void _set_source();
116                         void _to_history(Track t);
117                         void _truncate_history();
118                         int _awaiting_seek_pos;
119                         bool _awaiting_seek;
120                         QString _albumart;
121                 };
122         };
123 };
124
125 #endif // PLAYER_H