craftyguy
|
2010-02-13
, 05:41
|
Posts: 455 |
Thanked: 278 times |
Joined on Dec 2009
@ Oregon, USA
|
#11
|
|
2010-04-11
, 19:33
|
Posts: 197 |
Thanked: 101 times |
Joined on Dec 2009
@ Netherlands
|
#12
|
#!/usr/bin/env python # # A small script to learn and play with python, dbus, # mediaplayer and FM RDS # # Author: Mirakels (marcel@mesa.nl) # Date: april 2010 # # Setup dbus connections to mediaplayer en FMTx. Wait for # signals from mediaplyer and use them to show info on your # RDS capable audio system. It uses the RDS station name to # show the artist, and the RDS text field to show album and # title info of te current song. # # Note that mediaplayer also sets RDS when the FM transmitter # is enabled (at least it does so in PR 1.1.1). But it shows # artist/album/title as the RDS station name. This will be # 'overwritten' by this script. # # Just run this script in the background from an xterm: # # $ ./mp_rds.py & # # When you enable the FM transmitter in mediaplayer # RDS messages will be send to your radio... # import gobject, dbus from dbus.mainloop.glib import DBusGMainLoop album = "" title = "" # # Just some console fun to see what mediaplayer is doing # def handle_state(state): if (state == 0): print "Media player stopped" elif (state == 1): print "Media player start playing" elif (state == 2): print "Media player paused" elif (state == 3): print "Media player transitioning" else: print "Media player unknown state %d" % state # # Set RDS info based on mediaplayer tag info # def handle_meta(meta, state, data): # print "meta change meta=%s, state=%d data=%s" % (meta, state, data) global album global title if (meta == "artist"): artist = data fmtx_iface.Set("com.nokia.FMTx.Device", "rds_ps", dbus.String(u'%s' % data , variant_level=1)) if (meta == "title"): title = data info = title + ' / ' + album fmtx_iface.Set("com.nokia.FMTx.Device", "rds_text", dbus.String(u'%s' % info , variant_level=1)) if (meta == "album"): album = data info = title + ' / ' + album fmtx_iface.Set("com.nokia.FMTx.Device", "rds_text", dbus.String(u'%s' % info , variant_level=1)) DBusGMainLoop(set_as_default=True) # # Connect to mediaplayer # bus = dbus.SessionBus() bus.add_signal_receiver(handle_state, path='/com/nokia/mafw/renderer/gstrenderer', dbus_interface='com.nokia.mafw.renderer', signal_name='state_changed') bus.add_signal_receiver(handle_meta, path='/com/nokia/mafw/renderer/gstrenderer', dbus_interface='com.nokia.mafw.renderer', signal_name='metadata_changed') # # Create connection to FM transmitter # sysbus = dbus.SystemBus() fmtx = sysbus.get_object('com.nokia.FMTx', '/com/nokia/fmtx/default', False) fmtx_iface = dbus.Interface(fmtx, dbus_interface='org.freedesktop.DBus.Properties') gobject.MainLoop().run() # # The End #
|
2010-05-01
, 12:57
|
Posts: 169 |
Thanked: 41 times |
Joined on Apr 2010
@ Portugal
|
#13
|
|
2010-05-01
, 16:44
|
Posts: 169 |
Thanked: 41 times |
Joined on Apr 2010
@ Portugal
|
#14
|
|
2010-05-30
, 21:35
|
Posts: 1,667 |
Thanked: 561 times |
Joined on Feb 2010
|
#15
|
|
2010-05-30
, 21:43
|
Posts: 87 |
Thanked: 112 times |
Joined on Feb 2010
|
#16
|
|
2010-06-07
, 11:29
|
Posts: 55 |
Thanked: 76 times |
Joined on Dec 2009
|
#17
|
|
2010-06-22
, 12:43
|
Posts: 87 |
Thanked: 112 times |
Joined on Feb 2010
|
#18
|
|
2010-08-09
, 18:02
|
|
Posts: 55 |
Thanked: 14 times |
Joined on Mar 2010
|
#19
|
|
2010-08-10
, 05:34
|
Posts: 189 |
Thanked: 53 times |
Joined on Aug 2010
@ Netherlands
|
#20
|