Project

General

Profile

DBus trouble adding song to playlist in Python

Added by Kristian Kjærgaard about 11 years ago

I have a Python script that looks like this:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import gobject
import dbus
from dbus import glib

gobject.threads_init()
glib.init_threads()

bus = dbus.SessionBus()

remote_object = bus.get_object("org.atheme.audacious", "/org/atheme/audacious")
iface = dbus.Interface(remote_object, 'org.atheme.audacious')

song = "/home/user/song.mp3" 

iface.Pause()
iface.PlaylistAdd(song)
iface.Seek(55)
iface.Play()

But in the Audacious window, the song appears as the filename given in the string "song" and not as "Author - Title" as other songs do. When double-clicking the song I have to click OK to "No decoder found for /home/user/song.mp3."

What am I doing wrong?


Replies (4)

RE: DBus trouble adding song to playlist in Python - Added by John Lindgren about 11 years ago

Make sure the MP3 plugin is enabled?

RE: DBus trouble adding song to playlist in Python - Added by Kristian Kjærgaard about 11 years ago

If I drag and drop the file into Audacious it plays without trouble. The filename is also replaced with "Author - Title". The file plays if i execute "audacious /home/user/song.mp3". So the MP3 plugin should be enabled.

The debug messages related to the problem is written below.

probe.c:167 [file_find_decoder]: Probing /home/user/song.mp3.
probe.c:137 [probe_by_extension]: Probing by extension.
probe.c:111 [probe_func_fast]: Guessing MPG123 Plugin.
pluginenum.c:129 [plugin_load]: Loading plugin: /usr/lib/x86_64-linux-gnu/audacious/Input/madplug.so.
mpg123.c:66 [aud_mpg123_init]: initializing mpg123 library
plugin-registry.c:493 [plugin_register_loaded]: Loaded plugin: /usr/lib/x86_64-linux-gnu/audacious/Input/madplug.so

** (audacious:4435): CRITICAL **: vfs_fopen: assertion `s' failed

** (audacious:4435): CRITICAL **: playback_seek: assertion `playing' failed

** (audacious:4435): CRITICAL **: vfs_fopen: assertion `s' failed
util.c:215 [audgui_pixbuf_for_entry]: Using fallback pixbuf.
util.c:131 [audgui_simple_message]: /home/user/song.mp3 could not be opened.

I'm using Audacious 3.3.4 on Ubuntu 13.04

RE: DBus trouble adding song to playlist in Python - Added by Kristian Kjærgaard about 11 years ago

It seems I just forgot the protocol. If I append "file://" to my song filename in the Python script, everything works.

song = "file:///home/user/song.mp3" 

Sorry about the fuss.

RE: DBus trouble adding song to playlist in Python - Added by John Lindgren about 11 years ago

Hmm, yes, the D-Bus API is a pretty thin wrapper around the internal functions, and those expect a URI.

    (1-4/4)