2014-04-27 2 views
0

Specification page에 PlaybackStatus 속성을 org.mpris.mediaplayer2.player 사용하여 말한다 :이 특정 인터페이스에 대한 파이썬

print "Song %s" % iPlayer.PlaybackStatus 

또는

if iPlayer.PlaybackStatus == "Playing": 
    print "Song playing" 
:

PlaybackStatus — s (Playback_Status) 
. 
. 
. 
May be "Playing", "Paused" or "Stopped". 

을하지만 난 이런 식으로 읽을 때

매우 이상한 출력을 보여줍니다. <dbus.proxies._ProxyMethod instance at 0x255f248>

이 변수의 문자열 값에 어떻게 액세스합니까?

답변

2

재산을 얻으려면 Get 방법으로 전화해야합니다. 메서드는 문자열을 반환합니다. 나는 VLC 플레이어의 재생 상태를 얻기 위해 다음과 같은 한 : 내 경우

import dbus 

bus = dbus.SessionBus() 
vlc_media_player_obj = bus.get_object("org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2") 
props_iface = dbus.Interface(vlc_media_player_obj, 'org.freedesktop.DBus.Properties') 
pb_stat = props_iface.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus') 

을 (희망 당신의), 객체는 또한 당신이 위와 같이 호출 할 수 Get 방법을 가지고 org.freedesktop.DBus.Properties 인터페이스를했다.