RhythmBox有没有命令行界面或进程间通信的方法?

我真的很想通过一个网页服务器与rhythmbox进行通信,这样我就可以远程从我的智能手机上更改正在播放的音乐。是否有一个命令行界面可以用于rhythmbox执行类似下面(虚构的)命令的操作?
rhythmbox next
rhythmbox shuffle=false
rhythmbox change album='Dark Side of the Moon' artist='Pink Floyd' song='Time' 

有没有替代的插座或消息传递接口呢?是否有其他可以完成工作的替代程序,比如Banshee或其他类型的服务器?

可能是重复的问题吗?http://askubuntu.com/questions/21494/how-to-use-rhythmbox-client-on-lan - fossfreedom
可能是重复的问题吗?http://askubuntu.com/questions/150790/how-do-i-run-a-script-on-a-dbus-signal - fossfreedom
2@foss 不,这些问题中没有一个与 Geppeto 的答案相似。 - Braiam
1个回答

基本上,简短的答案是“是”,而补充说明的部分是“使用终端中的rhythmbox-client命令来控制当前正在运行的Rhythmbox,如果它还没有加载,则第一次运行命令将调用它。”
例如:rhythmbox-client --play会使当前的Rhythmbox会话开始播放当前歌曲(或列表中的第一首歌曲)。如果Rhythmbox被关闭,它将首先打开以开始播放。
关于rhythmbox-client及其使用的更多信息可以在rhythmbox-client man page中找到。我在此处仅提供man页的一部分供参考。
NAME
       rhythmbox-client - controls a running instance of rhythmbox

SYNOPSIS
       rhythmbox-client [option...][file...]

DESCRIPTION
       rhythmbox-client  is a tool for controlling an already running instance
       of  rhythmbox.   It's  useful  for  remote  control  scripting,  adding
       specific  files  to  the library from the shell, or printing details of
       what's playing. It also has an interactive mode, useful for controlling
       playback  remotely  via  ssh.  Any  files  specified  after  the option
       arguments will be added to the library.  If  the  --enqueue  option  is
       given, the files will also be added to the play queue.

OPTIONS
       -?,--help
              Show help options

       --debug
              Enable debug output

       --no-start
              Do not start a new instance of rhythmbox

       --quit Quit rhythmbox

       -i,--interactive
              Start  interactive  mode  --no-present Don't present an existing
              rhythmbox window

       --next Jump to next song

       --previous
              Jump to previous song

       --play Resume playback if currently paused

       --pause
              Pause playback if currently playing

       --play-pause
              Toggle play/pause mode

       --stop Stop playback if currently playing

       --play-uri=URI
              Play a specified URI, importing it if necessary

       --enqueue
              Add specified tracks already in the library to the play queue

       --clear-queue
              Empty the play queue before adding new tracks

       --print-playing
              Print the title and artist of the playing song

       --print-playing-format=format
              Print formatted details of the song (see FORMAT OPTIONS below).

       --set-volume
              Set the playback volume

       --volume-up
              Increase the playback volume

       --volume-down
              Decrease the playback volume

       --print-volume
              Print the current playback volume

       --select-source=URI
              Select the source corresponding to a URI (device or mount point)

       --activate-source=URI
              Select the source corresponding to a URI (device or mount point)
              and start playing from it if not already playing.

       --play-source=URI
              Select the source corresponding to a URI (device or mount point)
              and start playing from it.

FORMAT OPTIONS
       %at    album title

       %aa    album artist

       %aA    album artist (lowercase)

       %as    album artist sortname

       %aS    album artist sortname (lowercase)

       %ay    album year

       %ag    album genre

       %aG    album genre (lowercase)

       %an    album disc number

       %aN    album disc number, zero padded

       %st    stream title

       %tn    track number (i.e 8)

       %tN    track number, zero padded (i.e 08)

       %tt    track title

       %ta    track artist

       %tA    track artist (lowercase)

       %ts    track artist sortname

       %tS    track artist sortname (lowercase)

       %td    track duration

       %te    track elapsed time

       Variables can be combined using quotes. For example "%tn %aa %tt", will
       print  the  track  number  followed  by the artist and the title of the
       track.

AUTHOR
       This manual page was written by Sven Arvidsson  <sa@whiz.se>,  for  the
       Debian system (but may be used by others).

编辑

我对这个主题很感兴趣,所以我运行了下面的命令进行测试:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.rhythmbox /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:60000000

从这里发布的原始答案来看,确实适用于寻找当前播放的歌曲的任务(根据提问者的评论)。
祝你好运!

太棒了!那节省了我很多麻烦。你知道是否有“--seek”能力吗?在手册中没有包括它。 - Athan Clark
很不幸,rhythmbox-client选项有限。我已经为您方便起见在这个答案中添加了详细信息。 - Geppettvs D'Constanzo
请看这个答案:http://unix.stackexchange.com/a/75680,前面的--seek选项似乎已经被弃用了,但似乎还有另一种解决方案。如果你成功了,请告诉我们。谢谢。 - Geppettvs D'Constanzo
哎呀...我又给你做了一次修改。祝你好运! - Geppettvs D'Constanzo
原来Banshee有能力查询当前播放器信息(如正在播放的曲目、光标位置、播放器状态等)并控制播放!banshee --help将一切解释清楚!谢谢您的帮助,祝您度过愉快的一天! - Athan Clark
嗯,你的问题是关于Rhythmbox的,所以我主要集中在它上面。是的,今天我学到了一些新东西。谢谢!:D - Geppettvs D'Constanzo
有没有办法可以获取当前播放歌曲的文件名? - Abdulsattar Mohammed
嗨 @Asattar,没问题。你可以这样做。只需在终端中输入 rhythmbox-client --print-playing,你将会得到当前播放的歌曲名称和艺术家名称。如果你只想要一个参数,比如:只有歌曲名称,只需使用 --print-playing-format 并使用此答案中提到的格式选项。例如:rhythmbox-client --print-playing-format %tt,这将在终端中仅显示歌曲名称作为结果。祝你好运! - Geppettvs D'Constanzo
@GeppettvsD'Constanzo我已经查看了所有的格式选项,但是没有找到一个能给我提供文件名(例如/home/abdulsattar/Music/song.mp3)的选项。我需要这个文件名,因为我可以编写一个小的Shell脚本来删除当前播放的歌曲。 - Abdulsattar Mohammed
哦,是的。抱歉,我没明白那个。我会去找一下,找到后会为你修改。再次抱歉。 - Geppettvs D'Constanzo
我无法从命令行客户端中找到任何内容。然而,在org.gnome.Rhythmbox /org/gnome/Rhythmbox/Player中存在一个DBus方法。不幸的是,在Ubuntu 13.10中存在一个新的服务(org.gnome.Rhythmbox3),我无法找到任何能够提供当前播放URI的方法。 - Abdulsattar Mohammed