How to register Track changed

29 views
Skip to first unread message

Rainer Hihn

unread,
Mar 20, 2012, 11:02:26 AM3/20/12
to exaile...@googlegroups.com
Hi folks,

for a plugin development I need to register when a track ended / changed.
Is there an easy, convenient way to get this done?

Greetings

Mathias Brodala

unread,
Mar 20, 2012, 4:11:13 PM3/20/12
to exaile...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

Rainer Hihn, 20.03.2012 16:02:


> for a plugin development I need to register when a track ended /
> changed. Is there an easy, convenient way to get this done?

There are two events for that: playback_track_start and
playback_track_end, both emitted by xl.player.PLAYER. You can connect
to these the following way:

from xl import player
from xl import event

def on_playback_track_start(self, event, player, track):
"""
My callback for track start
"""
print "{0} started".format(track)

def on_playback_track_end(self, event, player, track):
"""
My callback for track end
"""
print "{0} ended".format(track)

event.add_callback(on_playback_track_start, "playback_track_start",
xl.player.PLAYER)
event.add_callback(on_playback_track_end, "playback_track_end",
xl.player.PLAYER)

Alternatively, if you write a class, you can derive from
xl.player.adapters.PlaybackAdapter and override its methods
on_playback_track_start and on_playback_track_end. The latter method
was missing until a few minutes ago but I’ve just added it.

Make sure to explicitely call its destroy() method within yours if you
derive from multiple classes. Otherwise you’ll leak callback references.


Regards, Mathias
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9o5FMACgkQYfUFJ3ewsJj6egCdEi1btgWPQ1MgfA2m06j6HxAp
R6kAni+fQwO5I/bBA5JVSo+BUTL2U79G
=bfCv
-----END PGP SIGNATURE-----

Mathias Brodala

unread,
Feb 21, 2013, 2:42:23 PM2/21/13
to exaile...@googlegroups.com
Hi,

Nike bl, 18.09.2012 12:53:
> Witch callback i must use to catch changes of tags in radio
> stream?

a late response, but look at the "track_tags_changed" event. Every
location where track info is displayed listens to this event.


Regards, Mathias
Reply all
Reply to author
Forward
0 new messages