本文整理汇总了Python中settings.Settings.isRandomStart方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.isRandomStart方法的具体用法?Python Settings.isRandomStart怎么用?Python Settings.isRandomStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.isRandomStart方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _updatePlaylistForSettings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isRandomStart [as 别名]
def _updatePlaylistForSettings(self, playlist):
if playlist.size() < 1:
return playlist
filename = playlist[0].getfilename()
duration = self._getVideoDuration(filename)
log("Duration is %d for file %s" % (duration, filename))
startTime = 0
# Check if we have a random start time
if Settings.isRandomStart():
startTime = random.randint(0, int(duration * 0.75))
clockStart = Settings.getTimeForClock(filename, duration)
if clockStart > 0:
startTime = clockStart
# Set the random start
if (startTime > 0) and (duration > 10):
listitem = xbmcgui.ListItem()
# Record if the theme should start playing part-way through
listitem.setProperty('StartOffset', str(startTime))
log("Setting start of %d for %s" % (startTime, filename))
# Remove the old item from the playlist
playlist.remove(filename)
# Add the new item at the start of the list
playlist.add(filename, listitem, 0)
return playlist
示例2: getThemePlaylist
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isRandomStart [as 别名]
def getThemePlaylist(self):
# Take the list of files and create a playlist from them
# Needs to be a Music playlist otherwise repeat will not work
# via the JSON interface
playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
playlist.clear()
for aFile in self.themeFiles:
# Add the theme file to a playlist
playlist.add(url=aFile)
# Check if we have more than one item in the playlist
if playlist.size() > 1:
# Check if we need to perform a shuffle of the available themes
if (not self.doNotShuffle) and (Settings.isShuffleThemes() or self.forceShuffle):
playlist.shuffle()
# Check if we are only supposed to play one theme when there are multiple
# available
if Settings.onlyPlaySingleTheme():
firstTheme = playlist[0].getfilename()
playlist.clear()
playlist.add(url=firstTheme)
# Now we have the playlist, and it has been shuffled if needed
# Check if we need to have a random start time for the first track
# Note: The following method (rather than seek) should prevent
# the seek dialog being displayed on the screen and also prevent
# the need to start the theme playing before changing the start point
if Settings.isRandomStart() and playlist.size() > 0:
filename = playlist[0].getfilename()
duration = int(playlist[0].getduration())
log("ThemeFiles: Duration is %d for file %s" % (duration, filename), self.debug_logging_enabled)
# Check if the duration of the file is showing as Zero, this means we need to
# try and find out the duration ourself
if duration < 1:
duration = VideoParser().getVideoLength(filename)
log("ThemeFiles: Manual find of duration is %d for file %s" % (duration, filename), self.debug_logging_enabled)
if duration > 10:
listitem = xbmcgui.ListItem()
# Check if there is a fixed start position
randomStart = Settings.getRandomFixedOffset(filename)
if (randomStart < 1) or (randomStart >= duration):
# Record if the theme should start playing part-way through
randomStart = random.randint(0, int(duration * 0.75))
listitem.setProperty('StartOffset', str(randomStart))
log("ThemeFiles: Setting Random start of %d for %s" % (randomStart, filename), self.debug_logging_enabled)
# Remove the old item from the playlist
playlist.remove(filename)
# Add the new item at the start of the list
playlist.add(filename, listitem, 0)
return playlist
示例3: _updatePlaylistForSettings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isRandomStart [as 别名]
def _updatePlaylistForSettings(self, playlist):
# Set the random start
if Settings.isRandomStart() and playlist.size() > 0:
filename = playlist[0].getfilename()
duration = self._getVideoDuration(filename)
log("Duration is %d for file %s" % (duration, filename))
if duration > 10:
listitem = xbmcgui.ListItem()
# Record if the theme should start playing part-way through
randomStart = random.randint(0, int(duration * 0.75))
listitem.setProperty('StartOffset', str(randomStart))
log("Setting Random start of %d for %s" % (randomStart, filename))
# Remove the old item from the playlist
playlist.remove(filename)
# Add the new item at the start of the list
playlist.add(filename, listitem, 0)
return playlist
示例4: getThemePlaylist
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isRandomStart [as 别名]
def getThemePlaylist(self):
# Take the list of files and create a playlist from them
playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
playlist.clear()
for aFile in self.themeFiles:
# Add the theme file to a playlist
playlist.add(url=aFile)
if (Settings.isShuffleThemes() or self.forceShuffle) and playlist.size() > 1:
playlist.shuffle()
# Now we have the playlist, and it has been shuffled if needed
# Check if we need to have a random start time for the first track
# Note: The following method (rather than seek) should prevent
# the seek dialog being displayed on the screen and also prevent
# the need to start the theme playing before changing the start point
if Settings.isRandomStart() and playlist.size() > 0:
filename = playlist[0].getfilename()
duration = int(playlist[0].getduration())
log("ThemeFiles: Duration is %d for file %s" % (duration, filename), self.debug_logging_enabled)
if duration > 10:
listitem = xbmcgui.ListItem()
# Record if the theme should start playing part-way through
randomStart = random.randint(0, int(duration * 0.75))
listitem.setProperty('StartOffset', str(randomStart))
log("ThemeFiles: Setting Random start of %d for %s" % (randomStart, filename), self.debug_logging_enabled)
# Remove the old item from the playlist
playlist.remove(filename)
# Add the new item at the start of the list
playlist.add(filename, listitem, 0)
return playlist
示例5: play
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isRandomStart [as 别名]
def play(self, item=None, listitem=None, windowed=True, fastFade=False):
self.tvtunesPlayerStarted = True
# if something is already playing, then we do not want
# to replace it with the theme
if not self.isPlaying():
self.updateVideoRefreshRate(item)
# Save the volume from before any alterations
self.original_volume = self._getVolume()
# Perform and lowering of the sound for theme playing
self._lowerVolume()
if Settings.isFadeIn():
# Get the current volume - this is our target volume
targetVol = self._getVolume()
cur_vol_perc = 1
# Calculate how fast to fade the theme, this determines
# the number of step to drop the volume in
numSteps = 10
if fastFade:
numSteps = numSteps / 2
vol_step = targetVol / numSteps
# Reduce the volume before starting
# do not mute completely else the mute icon shows up
self._setVolume(1)
# Now start playing before we start increasing the volume
xbmc.Player.play(self, item=item, listitem=listitem, windowed=windowed)
# Wait until playing has started
maxLoop = 100
while (not self.isPlaying()) and (not xbmc.abortRequested) and (maxLoop > 0):
maxLoop = maxLoop - 1
xbmc.sleep(30)
for step in range(0, (numSteps - 1)):
# If the system is going to be shut down then we need to reset
# everything as quickly as possible
if WindowShowing.isShutdownMenu() or xbmc.abortRequested:
log("ThemePlayer: Shutdown menu detected, cancelling fade in")
break
vol = cur_vol_perc + vol_step
log("ThemePlayer: fadeIn_vol: %s" % str(vol))
self._setVolume(vol)
cur_vol_perc = vol
xbmc.sleep(200)
# Make sure we end on the correct volume
self._setVolume(targetVol)
else:
xbmc.Player.play(self, item=item, listitem=listitem, windowed=windowed)
if Settings.isLoop():
xbmc.executebuiltin("PlayerControl(RepeatAll)")
# We no longer use the JSON method to repeat as it does not work with videos
# xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.SetRepeat", "params": {"playerid": 0, "repeat": "all" }, "id": 1 }')
# If we had a random start and we are looping then we need to make sure
# when it comes to play the theme for a second time it starts at the beginning
# and not from the same mid-point
if Settings.isRandomStart():
item[0].setProperty('StartOffset', "0")
else:
xbmc.executebuiltin("PlayerControl(RepeatOff)")
# We no longer use the JSON method to repeat as it does not work with videos
# xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.SetRepeat", "params": {"playerid": 0, "repeat": "off" }, "id": 1 }')
# Record the time that playing was started
self.startTime = int(time.time())
# Clear the current playlist, as we will re-populate it
self.playListItems = []
# Save off the number of items in the playlist
if item is not None:
self.playlistSize = item.size()
log("ThemePlayer: Playlist size = %d" % self.playlistSize)
# Store a list of all the tracks in the playlist
try:
i = 0
while i < self.playlistSize:
self.playListItems.append(item[i].getfilename())
i = i + 1
except:
log("ThemePlayer: Failed to save off playlist")
# Check if we are limiting each track in the list
if not Settings.isLoop():
# Already started playing the first, so the remaining number of
# tracks is one less than the total
self.remainingTracks = self.playlistSize - 1
self._setNextSkipTrackTime(self.startTime)
else:
self.playlistSize = 1
示例6: _updatePostPlayingForSettings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isRandomStart [as 别名]
def _updatePostPlayingForSettings(self, playlist):
# Check if we need to start at a random location
if Settings.isRandomStart() and playlist.size() > 0:
# Need to reset the offset to the start so that if it loops
# it will play from the start
playlist[0].setProperty('StartOffset', "0")
示例7: play
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isRandomStart [as 别名]
def play(self, item=None, listitem=None, windowed=False, fastFade=False):
# if something is already playing, then we do not want
# to replace it with the theme
if not self.isPlaying():
# Perform and lowering of the sound for theme playing
self._lowerVolume()
if Settings.isFadeIn():
# Get the current volume - this is out target volume
targetVol = self._getVolume()
cur_vol_perc = 1
# Calculate how fast to fade the theme, this determines
# the number of step to drop the volume in
numSteps = 10
if fastFade:
numSteps = numSteps / 2
vol_step = targetVol / numSteps
# Reduce the volume before starting
# do not mute completely else the mute icon shows up
self._setVolume(1)
# Now start playing before we start increasing the volume
xbmc.Player.play(self, item=item, listitem=listitem, windowed=windowed)
# Wait until playing has started
while not self.isPlayingAudio():
xbmc.sleep(30)
for step in range(0, (numSteps - 1)):
# If the system is going to be shut down then we need to reset
# everything as quickly as possible
if WindowShowing.isShutdownMenu() or xbmc.abortRequested:
log("Player: Shutdown menu detected, cancelling fade in")
break
vol = cur_vol_perc + vol_step
log("Player: fadeIn_vol: %s" % str(vol))
self._setVolume(vol)
cur_vol_perc = vol
xbmc.sleep(200)
# Make sure we end on the correct volume
self._setVolume(targetVol)
else:
xbmc.Player.play(self, item=item, listitem=listitem, windowed=windowed)
if Settings.isLoop():
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.SetRepeat", "params": {"playerid": 0, "repeat": "all" }, "id": 1 }')
# If we had a random start and we are looping then we need to make sure
# when it comes to play the theme for a second time it starts at the beginning
# and not from the same mid-point
if Settings.isRandomStart():
item[0].setProperty('StartOffset', "0")
else:
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.SetRepeat", "params": {"playerid": 0, "repeat": "off" }, "id": 1 }')
# Record the time that playing was started
self.startTime = int(time.time())
# Save off the number of items in the playlist
if item is not None:
self.playlistSize = item.size()
log("Player: Playlist size = %d" % self.playlistSize)
# Check if we are limiting each track in the list
if not Settings.isLoop():
# Already started laying the first, so the remaining number of
# tracks is one less than the total
self.remainingTracks = self.playlistSize - 1
self._setNextSkipTrackTime(self.startTime)
else:
self.playlistSize = 1