예제 #1
0
class CommandManager(object):
	def __init__(self):
		self.client = Client()
		self.splayer = StreamPlayer(self)
		self.splayer.start()

		self.commands = {
			'not_found': NotFoundCommand(None),
			'exit': ExitCommand(self),
			'clear': ClearCommand(None),
			'genres': GenresCommand(self),
			'play': PlayCommand(self),
			'pause': PauseCommand(self),
			'resume': ResumeCommand(self),
			'next': NextCommand(self),
			'prev': PrevCommand(self),
			'nextpage': NextPageCommand(self),
			'prevpage': PrevPageCommand(self),
			'loop': LoopCommand(self),
			'unloop': UnloopCommand(self),
			'seek': SimpleSeekCommand(self),
			'forwards': ForwardsCommand(self),
			'backwards': BackwardsCommand(self),
		}

	def update_player(self):
		self.splayer.change(self.client.current_stream_url())
		print('now playing \'' + self.client.current_track().title + '\'')

		if self.client.looping:
			print("looping track, use 'unloop' to disable looping")

	def gst_message_handler(self, bus, message):
		if message.type == gst.MESSAGE_EOS:
			if not self.client.looping:
				self.client.next_track()
			self.update_player()
예제 #2
0
	def __init__(self):
		self.client = Client()
		self.splayer = StreamPlayer(self)
		self.splayer.start()

		self.commands = {
			'not_found': NotFoundCommand(None),
			'exit': ExitCommand(self),
			'clear': ClearCommand(None),
			'genres': GenresCommand(self),
			'play': PlayCommand(self),
			'pause': PauseCommand(self),
			'resume': ResumeCommand(self),
			'next': NextCommand(self),
			'prev': PrevCommand(self),
			'nextpage': NextPageCommand(self),
			'prevpage': PrevPageCommand(self),
			'loop': LoopCommand(self),
			'unloop': UnloopCommand(self),
			'seek': SimpleSeekCommand(self),
			'forwards': ForwardsCommand(self),
			'backwards': BackwardsCommand(self),
		}