如何使用Python在Rhythmbox中获取当前播放的歌曲 [英] How do I get the currently playing song in Rhythmbox using Python

查看:270
本文介绍了如何使用Python在Rhythmbox中获取当前播放的歌曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu 12.04.我想使用Python访问Rhythymbox.

Im using Ubuntu 12.04. I want to access Rhythymbox using Python .

这是我到目前为止的工作方式:

This is how I've proceeded so far:

我已经浏览过该网站 https://live.gnome.org/RhythmboxPlugins/WritingGuide ,但它提供了有关如何进行操作的详细信息写插件,我现在对此不感兴趣.我已经看了一些教程,告诉我要这样做.

Ive gone through this site https://live.gnome.org/RhythmboxPlugins/WritingGuide , but it gives details on how to write plugins , which Im not interested in right now. Ive gone through a few tutorials which tells me to do this.

import dbus
session_bus = dbus.SessionBus()

proxy_obj = session_bus.get_object(
'org.gnome.Rhythmbox', '/org/gnome/Rhythmbox/Player') 

但是我遇到了以下错误

DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Rhythmbox was not provided by any .service files.

有人可以指出我要实现的正确方向吗?

Could someone please point me in the right direction of what I would like to achieve?

推荐答案

一种变通方法,由 lyricsdownloader使用. py ,是:

A workaround, used by lyricsdownloader.py, is:

import subprocess
import shlex

proc = subprocess.Popen(shlex.split('rhythmbox-client --no-start --print-playing-format %tt')))
title, err = proc.communicate()

注意:这不适用于没有rhythmbox-client的Ubuntu 11.10.

Note: This does not work with Ubuntu 11.10, which shipped without rhythmbox-client.

这篇关于如何使用Python在Rhythmbox中获取当前播放的歌曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆