Ubuntu – How to use Rhythmbox python console

pythonrhythmbox

Maybe this is obvious and I am missing it, or maybe someone's already written a great guide and my (seeming exhaustive) googling is failing to turn it up, but I cannot figure out for the life of me how to get the darn python console in rhythmbox to do anything!

I've enabled it from the plugin menu, and then open it using Tools->Python Console.

It prints

You can access the main window through the 'shell' variable :
<rb.Shell object at 0xa6cdd24 (RBShell at 0xa14e000)>
>>> 

But anything I type at the prompt does nothing!
I've tried help, I've tried exit(), I've tried print "hello world", nothing does anything!

All of these things work, of course, in a normal python console. I haven't a clue what the devil the difference is here! Am I supposed to do something other than hit enter?

Best Answer

The Rhythmbox Plugins Writing Guide has several examples of commands you can use in the Python console to control playback and modify Rhythmbox:

  • Play/Pause

    shell.props.shell_player.playpause()
    
  • Stop

    shell.props.shell_player.stop()
    
  • Next track

    shell.props.shell_player.do_next()
    
  • Add a song to the Play Queue

    shell.add_to_queue("file://awsome_song.ogg")
    
  • Display a visualization

    import gst
    goom = gst.element_factory_make ("goom")
    sink = gst.element_factory_make ("ximagesink")
    colour = gst.element_factory_make ("ffmpegcolorspace")
    b = gst.Bin()
    b.add (goom, colour, sink)
    b.add_pad(gst.GhostPad("sink", goom.get_pad("sink")))
    goom.link(colour)
    colour.link(sink)
    shell.get_player().props.player.add_tee(b)