class Notifier: PLAYING_STATE_EVENT = 0 PLAYBACK_VOLUME_EVENT = 1 PLAYBACK_RATE_EVENT = 2 def __init__(self, player): self._callbacks = dict() self._player = player self._player.setPlayingStateChangedCallback(self._playingStateChangedCallback) def registerCallback(self, event, callback): if event not in self._callbacks: self._callbacks[event] = list() self._callbacks[event].append(callback) def notify(self, event): for callback in self._callbacks.get(event, list()): callback() def _playingStateChangedCallback(self, *args): self.notify(Notifier.PLAYING_STATE_EVENT)