pythonrhythmbox

How to know if Rhythmbox is playing music or something else


I'm trying to solve a bug in this plugin. I want to show the sidebar only when playing music (not podcast or radio). My problem is I don't know what's the user is listening to. Can someone provide me with a way to do that? Thanks.


Solution

  • To get what is currently playing you'll need to:

    1. obtain the shell
    2. obtain the Rhythmbox Shell-Player from the shell.
    3. Get the playing entry from the ShellPlayer
    4. Find what the type the entry is.

    Lets go step-by-step

    Rhythmbox Shell

    The shell is a property of the plugin - self.props.shell. So lets save the shell with self.shell = self.props.shell

    Rhythmbox Shell Player

    The shell player is part of the shell properties - player = self.shell.props.shell_player

    Playing Entry

    The playing entry is found by interrogating the shell-player

    `entry = player.get_playing_entry()

    Entry Type

    From the entry you can get the entry-type:

    entrytype = entry.get_entry_type()

    From the documentation - you'll probably just need to test that the entry-type is Song i.e. entrytype.get_name() - other types are used for additional play streams.