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


Python Track.setVolume方法代码示例

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


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

示例1: TrackThreader

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import setVolume [as 别名]
class TrackThreader():
	def __init__(self):
		self.track = None
		self.onEndCustomCallback = None
		self.volume = volumizer.getJSON()['config']['milli']

	def __play_track(self, track, callback = None):
		self.setVolume(volumizer.getJSON()['config']['milli'])
		if(callback == None):
			track.play()
		else:
			callback(track)
		self.__oversee_track(track)
	
	#This makes track to disapear after it's done playing
	def __oversee_track(self, track):
		while (track.isBusy() or track.isPaused()) and not track.shouldEnd():
			continue
		if(self.onEndCustomCallback == None):
			if(self.track != None):
				print(self.track.getPath() + " finished playing.")
			self.setTrack(None)
		else:
			self.__play_track(track, self.onEndCustomCallback)

	def getThread(self, path):
		self.track = Track(path, self.volume)
		self.playingThread = threading.Thread(target = self.__play_track, args=(self.track, ))
		self.playingThread.daemon = True
		return {'thread' : self.playingThread,
				'track' : self.track}

	def currentTrack(self):
		return self.track

	def setTrack(self, track):
		self.track = track

	def setVolume(self, volume):
		self.volume = volume
		if self.track != None:
			self.track.setVolume(volume)

	def registerOnEndCustomCallback(self, callback):
		self.onEndCustomCallback = callback
开发者ID:Palkovsky,项目名称:AudioPi,代码行数:47,代码来源:threader.py

示例2: __init__

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import setVolume [as 别名]
class Playlist:

	def __init__(self, tracks, volume = 1):
		self.position = -1
		self.threadCount = len(tracks)
		self.volume = volume
		self.currentTrack = None
		self.tracks = tracks

	def loadTracks(self, tracks):
		self.tracks = tracks
		self.threadCount = len(tracks)

	def play(self, position = 0, onError = None):
		if len(self.tracks) > 0 and len(self.tracks) > position:
			self.position = position
			if onError == None:
				self.currentTrack = Track(self.tracks[self.position])
			else:
				self.currentTrack = Track(self.tracks[self.position], onError)
			self.currentTrack.setVolume(self.volume)
			self.currentTrack.play()
		else:
			raise IndexError('Wrong track position')

	def nextTrack(self, onError = None):
		if onError != None:
			self.play(self.position + 1, onError)
		else:
			self.play(self.position + 1)

	def previousTrack(self, onError = None):
		if onError != None:
			self.play(self.position - 1, onError)
		else:
			self.play(self.position - 1)

	def nextTrackAvilable(self):
		if len(self.tracks) > self.position + 1:
			return True
		return False

	def prevTrackAvilable(self):
		if len(self.tracks) > 0 and self.position - 1 >= 0:
			return True
		return False

	def setVolume(self, volume):
		if(volume > 1):
			volume = 1
		elif(volume < 0):
			volume = 0
		self.volume = volume
		self.currentTrack.setVolume(volume)

	def pause(self):
		self.currentTrack.pause()

	def unpause(self):
		self.currentTrack.unpause()

	def stop(self):
		self.currentTrack.stop()

	def isPaused(self):
		return self.currentTrack.isPaused()

	def isMuted(self):
		if self.currentTrack != None:
			return self.currentTrack.isMuted()
		return False

	def getVolume(self):
		return self.volume

	def isPlaying(self):
		if self.currentTrack != None:
			return self.currentTrack.isPlaying()
		return None

	def isPaused(self):
		if self.currentTrack != None:
			return self.currentTrack.isPaused()
		return None


	def getPosition(self):
		return self.position;

	def dispose(self):
		self.currentTrack.dispose()

	def onTrackEnd(self, callback):
		callback(self.position)

	def getTracks(self):
		return self.tracks

	def playbackInfo(self, code):

#.........这里部分代码省略.........
开发者ID:Palkovsky,项目名称:AudioPi,代码行数:103,代码来源:playlist.py


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