From 7f928395e907e0095e44da0a0998347dd689205f Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 14 Dec 2008 14:39:02 +0000 Subject: better mpris support git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@683 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/mpris/playerobject.cpp | 16 ++++++++++------ src/plugins/General/mpris/playerobject.h | 2 ++ src/qmmpui/mediaplayer.cpp | 5 +++++ src/qmmpui/mediaplayer.h | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/General/mpris/playerobject.cpp b/src/plugins/General/mpris/playerobject.cpp index 6a4aeb025..8175df301 100644 --- a/src/plugins/General/mpris/playerobject.cpp +++ b/src/plugins/General/mpris/playerobject.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "playerobject.h" @@ -55,6 +57,7 @@ PlayerObject::PlayerObject(QObject *parent) { qDBusRegisterMetaType(); m_core = SoundCore::instance(); + m_player = MediaPlayer::instance(); connect(m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(updateCaps())); connect(m_core, SIGNAL(metaDataChanged ()), SLOT(updateTrack())); connect(m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(updateStatus())); @@ -65,12 +68,12 @@ PlayerObject::~PlayerObject() void PlayerObject::Next() { - + m_player->next(); } void PlayerObject::Prev() { - + m_player->previous(); } void PlayerObject::Pause() @@ -80,12 +83,12 @@ void PlayerObject::Pause() void PlayerObject::Stop() { - m_core->stop(); + m_player->stop(); } void PlayerObject::Play() { - QMetaObject::invokeMethod(parent(), "play"); + m_player->play(); } PlayerStatus PlayerObject::GetStatus() @@ -140,9 +143,10 @@ int PlayerObject::GetCaps() caps |= CAN_PAUSE; else caps |= CAN_PLAY; - if (GetStatus().state < 2) + if ((GetStatus().state < 2) && (m_core->length() > 0)) caps |= CAN_SEEK; - caps |= CAN_PROVIDE_METADATA; + caps |= CAN_GO_NEXT; + caps |= CAN_GO_PREV; return caps; } diff --git a/src/plugins/General/mpris/playerobject.h b/src/plugins/General/mpris/playerobject.h index 0f60c85c9..1335b1138 100644 --- a/src/plugins/General/mpris/playerobject.h +++ b/src/plugins/General/mpris/playerobject.h @@ -24,6 +24,7 @@ #include class SoundCore; +class MediaPlayer; /** @author Ilya Kotov @@ -91,6 +92,7 @@ private slots: private: SoundCore *m_core; + MediaPlayer *m_player; }; diff --git a/src/qmmpui/mediaplayer.cpp b/src/qmmpui/mediaplayer.cpp index d317473e8..311b195b9 100644 --- a/src/qmmpui/mediaplayer.cpp +++ b/src/qmmpui/mediaplayer.cpp @@ -56,6 +56,11 @@ void MediaPlayer::initialize(SoundCore *core, PlayListModel *model) connect(m_core, SIGNAL(finished()), SLOT(next())); } +PlayListModel *MediaPlayer::playListModel() +{ + return m_model; +} + void MediaPlayer::play() { m_model->doCurrentVisibleRequest(); diff --git a/src/qmmpui/mediaplayer.h b/src/qmmpui/mediaplayer.h index f1717360b..fefc42978 100644 --- a/src/qmmpui/mediaplayer.h +++ b/src/qmmpui/mediaplayer.h @@ -39,6 +39,7 @@ public: static MediaPlayer* instance(); void initialize(SoundCore *core, PlayListModel *model); + PlayListModel *playListModel(); public slots: void play(); -- cgit v1.2.3-13-gbd6f