2 # -*- coding: utf-8 -*-
3 """Core Object dealing with plugins and player client
6 __version__ = '0.12.0.b'
7 __author__ = 'kaliko jack'
8 __url__ = 'git://git.kaliko.me/sima.git'
10 from logging import getLogger
12 from .client import PlayerClient
15 """Main class, plugin and player management
19 self.log = getLogger('sima')
23 self.current_track = None
25 def register_plugin(self, plugin_class):
26 self.plugins.append(plugin_class(self))
28 def foreach_plugin(self, method, *args, **kwds):
29 for plugin in self.plugins:
30 getattr(plugin, method)(*args, **kwds)
32 def connect_player(self):
33 """Instanciate player client and connect
35 self.player = PlayerClient() # Player client
39 """General shutdown method
41 self.player.disconnect()
42 self.foreach_plugin('shutdown')
45 """Dispatching callbacks to plugins
47 self.log.debug(self.player.status())
48 self.log.info(self.player.current)
50 # hanging here untill a monitored event is raised in the player
51 changed = self.player.monitor()
52 if 'playlist' in changed:
53 self.foreach_plugin('callback_playlist')
54 if 'player' in changed:
55 self.log.info(self.player.current)
59 # vim: ai ts=4 sw=4 sts=4 expandtab