Friday, February 23, 2007

XMMS + aMSN

I found a plug-in for aMSN which can display currently playing music in a personal message. It supports quite many players including XMMS I'm using. It uses xmms-infopipe to get information about the playing song. The infopipe itself seems to be buggy and especially with this music plug-in. The XMMS starts to use from 30% to 80% of CPU and every time aMSN refreshes the song name the CPU usage increases to 100% and the messengers hangs for a couple of seconds. It's pretty annoying especially when I'm typing. And I'm not the only one having such a problem. Somebody was trying to rewrite the infopipe or music.tcl. I found another way to solve the problem. I wrote a short script in python and saved it as infoxmms in the plug-in directory. You'll need PyXMMS for it to work:

import sys
try:
    import xmms
except:
    print 0
else:
    if xmms.control.is_playing():
        current = xmms.control.get_playlist_pos()
        title = xmms.control.get_playlist_title(current)
        print title
    else:
        print 0

And modified two functions in music.tcl:

proc TreatSongXMMS {} {
    after 0 {::music::exec_async [list "python" [file join $::music::musicpluginpath "infoxmms"]]}
    return 0
}

proc GetSongXMMS {} {
    if { [catch {split $::music::actualsong "\n"} song] } {
        return 0
    }

    if {$song == "0"} {
        return 0
    } else {
        return $song
    }
}

It works just fine without using much CPU time and hanging the messenger.

 (481x394, 98Kb)

No comments: