11#include < QApplication>
22
3+ #include " playerinfo.h"
4+ #include " playermanager.h"
5+ #include " controlobject.h"
6+
37#include " mediaplayer2player.h"
48
9+ static const char * kPlaybackStatusPlaying = " Playing" ;
10+ static const char * kPlaybackStatusPaused = " Paused" ;
11+ static const char * kPlaybackStatusStopped = " Stopped" ;
12+
13+ // the playback will stop when there are no more tracks to play
14+ static const char * kLoopStatusNone = " None" ;
15+ // The current track will start again from the begining once it has finished playing
16+ static const char * kLoopStatusTrack = " Track" ;
17+ // The playback loops through a list of tracks
18+ static const char * kLoopStatusPlaylist = " Playlist" ;
19+
20+
521MediaPlayer2Player::MediaPlayer2Player (QObject *parent)
622 : QDBusAbstractAdaptor(parent) {
723}
@@ -10,21 +26,48 @@ MediaPlayer2Player::~MediaPlayer2Player() {
1026}
1127
1228QString MediaPlayer2Player::playbackStatus () const {
13- QString playbackStatus;
14- return playbackStatus;
29+ TrackPointer pTrack;
30+ pTrack = PlayerInfo::instance ().getCurrentPlayingTrack ();
31+ if (!pTrack.isNull ()) {
32+ return QString (kPlaybackStatusPlaying );
33+ } else {
34+ // TODO: Decide how to handle the mpris Pause state
35+ return QString (kPlaybackStatusStopped );
36+ }
1537}
1638
1739QString MediaPlayer2Player::loopStatus () const {
18- QString loopStatus;
19- return loopStatus;
40+ TrackPointer pTrack;
41+ int deckIndex = PlayerInfo::instance ().getCurrentPlayingDeck ();
42+ if (deckIndex >= 0 ) {
43+ QString group = PlayerManager::groupForDeck (deckIndex);
44+ ConfigKey key (group, " repeat" );
45+ if (ControlObject::get (key) > 0.0 ) {
46+ return QString (kLoopStatusTrack );
47+ }
48+ // TODO: Decide when how to Handle playlist repeat mode
49+ }
50+ return QString (kLoopStatusNone );
2051}
2152
2253void MediaPlayer2Player::setLoopStatus (const QString& value) {
23- Q_UNUSED (value);
54+ double repeat = 0.0 ;
55+ if (value == kLoopStatusTrack ) {
56+ repeat = 1.0 ;
57+ }
58+
59+ TrackPointer pTrack;
60+ int deckIndex = PlayerInfo::instance ().getCurrentPlayingDeck ();
61+ if (deckIndex >= 0 ) {
62+ QString group = PlayerManager::groupForDeck (deckIndex);
63+ ConfigKey key (group, " repeat" );
64+ ControlObject::set (key, repeat);
65+ // TODO: Decide when how to handle playlist repeat mode
66+ }
2467}
2568
2669double MediaPlayer2Player::rate () const {
27- double rate = 0 .0 ;
70+ double rate = 1 .0 ;
2871 return rate;
2972}
3073
@@ -61,11 +104,11 @@ qlonglong MediaPlayer2Player::position() const {
61104}
62105
63106double MediaPlayer2Player::minimumRate () const {
64- return 0 .0 ;
107+ return 1 .0 ;
65108}
66109
67110double MediaPlayer2Player::maximumRate () const {
68- return 0 .0 ;
111+ return 1 .0 ;
69112}
70113
71114bool MediaPlayer2Player::canGoNext () const {
@@ -81,7 +124,7 @@ bool MediaPlayer2Player::canPlay() const {
81124}
82125
83126bool MediaPlayer2Player::canPause () const {
84- return false ;
127+ return true ;
85128}
86129
87130bool MediaPlayer2Player::canSeek () const {
@@ -99,12 +142,26 @@ void MediaPlayer2Player::Previous() {
99142}
100143
101144void MediaPlayer2Player::Pause () {
145+ TrackPointer pTrack;
146+ int deckIndex = PlayerInfo::instance ().getCurrentPlayingDeck ();
147+ if (deckIndex >= 0 ) {
148+ QString group = PlayerManager::groupForDeck (deckIndex);
149+ ConfigKey key (group, " play" );
150+ ControlObject::set (key, 0.0 );
151+ }
102152}
103153
104154void MediaPlayer2Player::PlayPause () {
105155}
106156
107157void MediaPlayer2Player::Stop () {
158+ TrackPointer pTrack;
159+ int deckIndex = PlayerInfo::instance ().getCurrentPlayingDeck ();
160+ if (deckIndex >= 0 ) {
161+ QString group = PlayerManager::groupForDeck (deckIndex);
162+ ConfigKey key (group, " play" );
163+ ControlObject::set (key, 0.0 );
164+ }
108165}
109166
110167void MediaPlayer2Player::Play () {
0 commit comments