def track(event, args, kwargs): if event is PlayerEventCallbacks.onSongChange: oldSong = kwargs["oldSong"] newSong = kwargs["newSong"] lastfm.onSongChange(newSong) if event is PlayerEventCallbacks.onSongFinished: song = kwargs["song"] lastfm.onSongFinished(song)
def track(event, args, kwargs): # Note that we can get an `onSongChange` when we are not playing, # e.g. at startup (first song) or when the user presses `nextSong`. # So it might make sense to delay that here... # We don't for now for simplicity reasons... if event is PlayerEventCallbacks.onSongChange: oldSong = kwargs["oldSong"] newSong = kwargs["newSong"] lastfm.onSongChange(newSong) if event is PlayerEventCallbacks.onSongFinished: song = kwargs["song"] timestamp = kwargs["timestamp"] lastfm.onSongFinished(song, timestamp=timestamp)
def track(event, args, kwargs): print "track:", repr(event), repr(args), repr(kwargs) if event is PlayerEventCallbacks.onSongChange: oldSong = kwargs["oldSong"] if oldSong: oldSong.close() # in case anyone is holding any ref to it, close at least the file newSong = kwargs["newSong"] if "artist" not in newSong.metadata: print "new song metadata is incomplete:", newSong.metadata else: print "new song:", newSong.fileext, ",", newSong.artist, "-", newSong.track, ",", formatTime(newSong.duration) pprint(newSong.metadata) lastfm.onSongChange(newSong) if event is PlayerEventCallbacks.onSongFinished: song = kwargs["song"] lastfm.onSongFinished(song)