diff options
| author | 2008-05-01 13:21:48 +0000 | |
|---|---|---|
| committer | 2008-05-01 13:21:48 +0000 | |
| commit | d61007df2929ac665abe92601e2ddf45cced208b (patch) | |
| tree | b2d9d9bff22fedb077729bba05ffd9da7ac8405d /src/modules/mediaplayer/mp_audaciousinterface.cpp | |
| parent | better file loading (diff) | |
| download | KVIrc-d61007df2929ac665abe92601e2ddf45cced208b.tar.gz KVIrc-d61007df2929ac665abe92601e2ddf45cced208b.tar.bz2 KVIrc-d61007df2929ac665abe92601e2ddf45cced208b.zip | |
implement getVol in audacious mediaplayer interface
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1637 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/mediaplayer/mp_audaciousinterface.cpp')
| -rw-r--r-- | src/modules/mediaplayer/mp_audaciousinterface.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/modules/mediaplayer/mp_audaciousinterface.cpp b/src/modules/mediaplayer/mp_audaciousinterface.cpp index 89980e425..cabfb8ab9 100644 --- a/src/modules/mediaplayer/mp_audaciousinterface.cpp +++ b/src/modules/mediaplayer/mp_audaciousinterface.cpp @@ -100,19 +100,22 @@ bool KviAudaciousInterface::quit() AUDACIOUS_SIMPLE_CALL("Quit") } +#define AUDACIOUS_CALL_METHOD(__method, __return_if_fail) \ + QDBusInterface dbus_iface("org.mpris.audacious", "/Player", \ + "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus()); \ + QDBusMessage reply = dbus_iface.call(QDBus::Block, __method); \ + if (reply.type() == QDBusMessage::ErrorMessage) { \ + QDBusError err = reply; \ + debug("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); \ + return __return_if_fail; \ + } + QString KviAudaciousInterface::nowPlaying() { if (this->status() != KviMediaPlayerInterface::Playing) return ""; - QDBusInterface dbus_iface("org.mpris.audacious", "/Player", - "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus()); - QDBusMessage reply = dbus_iface.call(QDBus::Block, "GetMetadata"); - if (reply.type() == QDBusMessage::ErrorMessage) { - QDBusError err = reply; - debug("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); - return ""; - } + AUDACIOUS_CALL_METHOD("GetMetadata", "") QString artist; QString title; @@ -138,14 +141,7 @@ QString KviAudaciousInterface::nowPlaying() QString KviAudaciousInterface::mrl() { - QDBusInterface dbus_iface("org.mpris.audacious", "/Player", - "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus()); - QDBusMessage reply = dbus_iface.call(QDBus::Block, "GetMetadata"); - if (reply.type() == QDBusMessage::ErrorMessage) { - QDBusError err = reply; - debug("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); - return ""; - } + AUDACIOUS_CALL_METHOD("GetMetadata", "") foreach (QVariant v, reply.arguments()) { QDBusArgument arg = qvariant_cast<QDBusArgument>(v); @@ -162,6 +158,14 @@ QString KviAudaciousInterface::mrl() return ""; } +int KviAudaciousInterface::getVol() +{ + AUDACIOUS_CALL_METHOD("VolumeGet", -1) + + int iVol = reply.arguments().first().toInt(); + return iVol * 255 /100; +} + KviMediaPlayerInterface::PlayerStatus KviAudaciousInterface::status() { QDBusInterface dbus_iface("org.mpris.audacious", "/Player", @@ -181,14 +185,7 @@ KviMediaPlayerInterface::PlayerStatus KviAudaciousInterface::status() int KviAudaciousInterface::length() { - QDBusInterface dbus_iface("org.mpris.audacious", "/Player", - "org.freedesktop.MediaPlayer", QDBusConnection::sessionBus()); - QDBusMessage reply = dbus_iface.call(QDBus::Block, "GetMetadata"); - if (reply.type() == QDBusMessage::ErrorMessage) { - QDBusError err = reply; - debug("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message())); - return -1; - } + AUDACIOUS_CALL_METHOD("GetMetadata", -1) foreach (QVariant v, reply.arguments()) { QDBusArgument arg = qvariant_cast<QDBusArgument>(v); |
