3
# =============================================================================
5
# Remuco - A remote control system for media players.
6
# Copyright (C) 2006-2009 Oben Sonne <obensonne@googlemail.com>
8
# This file is part of Remuco.
10
# Remuco is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
15
# Remuco is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
20
# You should have received a copy of the GNU General Public License
21
# along with Remuco. If not, see <http://www.gnu.org/licenses/>.
23
# =============================================================================
25
"""Remuco player adapter for Amarok, implemented as an executable script."""
28
from dbus.exceptions import DBusException
32
from remuco import log
34
# =============================================================================
36
# =============================================================================
38
class AmarokAdapter(remuco.MPRISAdapter):
42
remuco.MPRISAdapter.__init__(self, "amarok", "Amarok",
43
mime_types=("audio",), rating=True)
49
remuco.MPRISAdapter.start(self)
52
bus = dbus.SessionBus()
53
proxy = bus.get_object("org.kde.amarok", "/amarok/MainWindow")
54
self.__am = dbus.Interface(proxy, "org.kde.KMainWindow")
55
except DBusException, e:
56
raise StandardError("dbus error: %s" % e)
60
remuco.MPRISAdapter.stop(self)
66
remuco.MPRISAdapter.poll(self)
68
# amarok does not signal change in shuffle state
71
# =========================================================================
73
# =========================================================================
75
def ctrl_rate(self, rating):
77
rating = min(rating, 5)
78
rating = max(rating, 1)
79
action = "rate%s" % rating
82
self.__am.activateAction(action)
83
except DBusException, e:
84
log.warning("dbus error: %s" % e)
86
def ctrl_toggle_shuffle(self):
88
remuco.MPRISAdapter.ctrl_toggle_shuffle(self)
90
# amarok does not signal change in shuffle state
91
gobject.idle_add(self._poll_status)
93
# =============================================================================
95
# =============================================================================
97
if __name__ == '__main__':
100
mg = remuco.Manager(pa, player_dbus_name="org.mpris.amarok")