2 # -*- coding: utf-8 -*-
4 from .client import PlayerClient
7 """Main class, plugin and player management
15 def register_plugin(self, plugin_class):
16 self.plugins.append(plugin_class(self))
18 def foreach_plugin(self, method, *args, **kwds):
19 for plugin in self.plugins:
20 getattr(plugin, method)(*args, **kwds)
22 def connect_player(self):
23 """Instanciate player client and connect it
25 self.player = PlayerClient() # Player client
29 """General shutdown method
31 self.player.disconnect()
32 self.foreach_plugin('shutdown')
35 """Dispatching callbacks to plugins
37 print(self.player.status())
39 # hanging here untill a monitored event is raised in the player
40 changed = self.player.monitor()
42 print(self.player.current)
43 if 'playlist' in changed:
44 self.foreach_plugin('callback_playlist')
45 if 'player' in changed:
51 # vim: ai ts=4 sw=4 sts=4 expandtab