当前位置: 首页>>代码示例>>Python>>正文


Python Playlist.previous方法代码示例

本文整理汇总了Python中playlist.Playlist.previous方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.previous方法的具体用法?Python Playlist.previous怎么用?Python Playlist.previous使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playlist.Playlist的用法示例。


在下文中一共展示了Playlist.previous方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import previous [as 别名]
class Player:
	def __init__(self, name, modules, config, serverHttpRequest, serverMq):
		self.name = name
		self.serverMq = serverMq;
		self.playerModules = dict();
		for moduleClass in modules:
			print "loading player module " + moduleClass["moduleName"]
			self.playerModules[moduleClass["moduleName"]] = moduleClass["class"](config, self.next)
		self.playlist = Playlist(config.get("Server", "name"), serverHttpRequest);
		self.currentPlayer = None;
		self.job = None

	def getPlayer(self, name):
		LOGGER.info("getting player " + name)
		return self.playerModules[name]

	def switchPlayer(self, name):
		next = self.getPlayer(name)
		if self.currentPlayer is None or next != self.currentPlayer:
			if self.currentPlayer is not None:
				self.currentPlayer.pause()
			self.currentPlayer = next

	def play(self, track=None):
		track = track or self.playlist.get()
		if track is not None:
			LOGGER.info("playing (name: " + str(track.name) + ", uri: " + str(track.uri) + ") on: " + track.source)
			self.switchPlayer(track.source)
			if self.currentPlayer.play(track) is False:
				self.next();
			else:
				self.serverMq.emit("player:status", {'status':'PLAYING', "playingId": track._id, "track": track.jsonFull})
				#self.setSendProgressJob()
		else:
			if self.job is not None:
				self.job.remove()
			self.serverMq.emit("player:status", {'status':"PAUSED"})
			LOGGER.info("playlist empty")


	def resume(self):
		LOGGER.info("curent track = " + str(self.currentPlayer.currentTrack));
		if self.currentPlayer.currentTrack is None:
			self.play()
		else:
			self.currentPlayer.resume()
			LOGGER.info("emit 'player:status' => 'PLAYING'")
			self.serverMq.emit("player:status", {'status':'PLAYING'})
			self.setSendProgressJob()


	def pause(self):
		self.currentPlayer.pause()
		if self.job is not None:
			self.job.remove()
		self.serverMq.emit("player:status", {'status':"PAUSED"})


	def next(self):
		next = self.playlist.next();
		if next is None:
			LOGGER.info("Nothing after")
			self.pause()
			return None
		else:
			LOGGER.info("playing next")
			self.play(next)
			return next;


	def previous(self):
		previous = self.playlist.previous();
		if previous is not None:
			self.play(previous)
		else:
			self.pause()
开发者ID:homyPi,项目名称:homyPi_raspberryApp,代码行数:78,代码来源:player.py


注:本文中的playlist.Playlist.previous方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。