From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 7/7] test: Add support for using external player
Date: Mon, 29 Oct 2012 16:41:49 +0200 [thread overview]
Message-ID: <1351521709-4063-7-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1351521709-4063-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This add support for passing a device player object which is then
registered as a local one in a loopback fashion.
---
test/simple-player | 80 +++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 61 insertions(+), 19 deletions(-)
diff --git a/test/simple-player b/test/simple-player
index f8751d6..9e72f3e 100755
--- a/test/simple-player
+++ b/test/simple-player
@@ -9,6 +9,50 @@ import dbus.mainloop.glib
import gobject
class Player(dbus.service.Object):
+ properties = None
+ metadata = None
+
+ def set_object(self, obj = None):
+ if obj != None:
+ bus = dbus.SystemBus()
+ mp = dbus.Interface(bus.get_object("org.bluez", obj),
+ "org.bluez.MediaPlayer")
+
+ self.properties = mp.GetProperties()
+ self.metadata = mp.GetTrack()
+
+ bus.add_signal_receiver(self.property_changed,
+ path = obj,
+ dbus_interface = "org.bluez.MediaPlayer",
+ signal_name = "PropertyChanged")
+
+ bus.add_signal_receiver(self.track_changed,
+ path = obj,
+ dbus_interface ="org.bluez.MediaPlayer",
+ signal_name = "TrackChanged")
+ else:
+ self.properties = dbus.Dictionary({
+ "Equalizer" : "off",
+ "Repeat" : "off",
+ "Shuffle" : "off",
+ "Scan" : "off",
+ "Status" : "playing",
+ "Position" : dbus.UInt32(0) },
+ signature="sv")
+
+ self.metadata = dbus.Dictionary({
+ "Title" : "Title",
+ "Artist" : "Artist",
+ "Album" : "Album",
+ "Genre" : "Genre",
+ "NumberOfTracks" : dbus.UInt32(10),
+ "Track" : dbus.UInt32(1),
+ "Duration" : dbus.UInt32(10000) },
+ signature="sv")
+ handler = InputHandler(self)
+ gobject.io_add_watch(sys.stdin, gobject.IO_IN,
+ handler.handle)
+
@dbus.service.method("org.bluez.MediaPlayer",
in_signature="", out_signature="")
def Release(self):
@@ -42,6 +86,16 @@ class Player(dbus.service.Object):
def help(self, func):
help(self.__class__.__dict__[func])
+ def property_changed(self, setting, value):
+ print("property_changed(%s, %s)" % (setting, value))
+
+ self.PropertyChanged(setting, value)
+
+ def track_changed(self, metadata):
+ print("track_changed(%s)" % (metadata))
+
+ self.TrackChanged(metadata)
+
class InputHandler:
commands = { 'TrackChanged': '(metadata)',
'PropertyChanged': '(key, value)',
@@ -79,7 +133,6 @@ class InputHandler:
return True
-
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -99,27 +152,16 @@ if __name__ == '__main__':
player = Player(bus, path)
mainloop = gobject.MainLoop()
- properties = dbus.Dictionary({ "Equalizer" : "off",
- "Repeat" : "off",
- "Shuffle" : "off",
- "Scan" : "off",
- "Status" : "playing",
- "Position" : dbus.UInt32(0) }, signature="sv")
-
- metadata = dbus.Dictionary({ "Title" : "Title",
- "Artist" : "Artist",
- "Album" : "Album",
- "Genre" : "Genre",
- "NumberOfTracks" : dbus.UInt32(10),
- "Track" : dbus.UInt32(1),
- "Duration" : dbus.UInt32(10000) }, signature="sv")
+ if len(sys.argv) > 2:
+ player.set_object(sys.argv[2])
+ else:
+ player.set_object()
print('Register media player with:\n\tProperties: %s\n\tMetadata: %s' \
- % (properties, metadata))
+ % (player.properties, player.metadata))
- handler = InputHandler(player)
- gobject.io_add_watch(sys.stdin, gobject.IO_IN, handler.handle)
- media.RegisterPlayer(dbus.ObjectPath(path), properties, metadata)
+ media.RegisterPlayer(dbus.ObjectPath(path), player.properties,
+ player.metadata)
mainloop.run()
--
1.7.11.7
next prev parent reply other threads:[~2012-10-29 14:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-29 14:41 [PATCH BlueZ 1/7] AVRCP: Add initial support for controller player Luiz Augusto von Dentz
2012-10-29 14:41 ` [PATCH BlueZ 2/7] audio: Export remote player as children object path of device Luiz Augusto von Dentz
2012-10-29 14:41 ` [PATCH BlueZ 3/7] player: Add support for SetProperty Luiz Augusto von Dentz
2012-10-29 15:41 ` Lucas De Marchi
2012-10-30 8:49 ` Luiz Augusto von Dentz
2012-10-29 14:41 ` [PATCH BlueZ 4/7] AVRCP: Remove conversions inside media.c Luiz Augusto von Dentz
2012-10-29 14:41 ` [PATCH BlueZ 5/7] test: Fix using Number instead of Track in simple-player Luiz Augusto von Dentz
2012-10-29 14:41 ` [PATCH BlueZ 6/7] test: Fix using Number instead of Track in mpris-player Luiz Augusto von Dentz
2012-10-29 14:41 ` Luiz Augusto von Dentz [this message]
2012-10-31 8:39 ` [PATCH BlueZ 1/7] AVRCP: Add initial support for controller player Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351521709-4063-7-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).