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


Python Settings.isShuffleThemes方法代码示例

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


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

示例1: getThemePlaylist

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isShuffleThemes [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
开发者ID:kodibrasil,项目名称:KodiBrasil,代码行数:58,代码来源:themeFinder.py

示例2: _filterForVideoThemesRule

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isShuffleThemes [as 别名]
    def _filterForVideoThemesRule(self):
        # Check if we just leave the list as it is
        if not Settings.isVideoThemesFirst() and not Settings.isVideoThemesOnlyIfOneExists():
            return False

        # Go through each file seeing if it ends with one of the expected
        # video formats that we support
        containsVideoFile = False
        for aThemeFile in self.themeFiles:
            if Settings.isVideoFile(aThemeFile):
                containsVideoFile = True
                break

        # Check if there are no video files, so nothing to do
        if not containsVideoFile:
            return False

        # Now strip out anything that is not a video file
        videoThemes = []
        audioThemes = []
        for aThemeFile in self.themeFiles:
            if Settings.isVideoFile(aThemeFile):
                videoThemes.append(aThemeFile)
            else:
                audioThemes.append(aThemeFile)

        # Check if we need to only return video themes if one exists
        # and we don't want audio themes in this case
        if Settings.isVideoThemesOnlyIfOneExists():
            log("ThemeFiles: Removing non video themes", self.debug_logging_enabled)
            self.themeFiles = videoThemes
        elif Settings.isVideoThemesFirst():
            # If we want to shuffle the tracks, then do this before we join the
            # two arrays together
            if Settings.isShuffleThemes():
                random.shuffle(videoThemes)
                random.shuffle(audioThemes)
            self.themeFiles = videoThemes + audioThemes
            return True

        return False
开发者ID:kodibrasil,项目名称:KodiBrasil,代码行数:43,代码来源:themeFinder.py

示例3: getThemePlaylist

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import isShuffleThemes [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
开发者ID:nspierbundel,项目名称:OpenELEC.tv,代码行数:38,代码来源:themeFinder.py


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