Implemented new features:
[someplayer] / src / player / player.h
1 #ifndef PLAYER_H
2 #define PLAYER_H
3
4 #include <QObject>
5 #include "../someplayer.h"
6 #include "../track.h"
7 #include "../trackmetainformation.h"
8 #include "../playlist.h"
9 #include <phonon/MediaObject>
10 #include <phonon/AudioOutput>
11 #include <phonon/VolumeSlider>
12 #include <QStack>
13 #include <QQueue>
14
15 // represents player
16
17 using SomePlayer::DataObjects::Track;
18 using SomePlayer::DataObjects::TrackMetadata;
19 using SomePlayer::DataObjects::Playlist;
20 using SomePlayer::Storage::Config;
21
22 namespace SomePlayer {
23         namespace Playback {
24
25                 enum PlayerState { PLAYER_STOPPED, PLAYER_PLAYING, PLAYER_PAUSED, PLAYER_LOADING, PLAYER_DONE, PLAYER_ERROR };
26
27                 class Player : public QObject
28                 {
29                         Q_OBJECT
30                 public:
31                         explicit Player(QObject *parent = 0);
32
33                         bool random() {return _random;}
34                         bool repeat() {return _repeat;}
35                         int volume() {return (int)(_output->volume()*100 + 0.5);}
36                         Phonon::MediaObject* mediaObject() {return _player;}
37
38                 signals:
39                         void stateChanged (PlayerState);
40                         void trackChanged (Track);
41                         void tick (int, int); // played | all (seconds)
42                         void trackDone(Track);
43
44                 public slots:
45                         void setTrackId(int id);
46                         void enqueue(int id);
47                         void toggle();
48                         void play();
49                         void stop();
50                         void next();
51                         void prev();
52                         void setPlaylist(Playlist);
53                         void toggleRandom();
54                         void toggleRepeat();
55                         void seek(int);
56                         void setVolume(int);
57                 private slots:
58                         void _stateChanged(Phonon::State, Phonon::State);
59                         void _tick(qint64);
60                 private:
61                         int _current;
62                         Track _track; // current track (workaround)
63                         bool _random;
64                         bool _repeat;
65                         QStack<int> _history;
66                         QQueue<int> _queue;
67                         QStack<int> _prev_history;
68                         Playlist _playlist;
69                         Phonon::MediaObject *_player;
70                         Phonon::AudioOutput *_output;
71                         PlayerState _state;
72                         Config _config;
73
74                         void _set_source();
75
76                 };
77         };
78 };
79
80 #endif // PLAYER_H