Beispiel #1
0
    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:
            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(
                "MusicThemeFiles: 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(
                    "MusicThemeFiles: 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(
                    "MusicThemeFiles: 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
    def getDuration(self):
        if self.duration is None:
            try:
                # Parse the video file for the duration
                self.duration = VideoParser().getVideoLength(self.filename)
                log("BaseExtrasItem: Duration retrieved is = %d" % self.duration)
            except:
                log("BaseExtrasItem: Failed to get duration from %s" % self.filename)
                log("BaseExtrasItem: %s" % traceback.format_exc())
                self.duration = 0

        return self.duration
Beispiel #3
0
    def _getVideoDuration(self, filename):
        duration = 0
        try:
            # Parse the video file for the duration
            duration = VideoParser().getVideoLength(filename)
        except:
            log("Failed to get duration from %s" % filename, xbmc.LOGERROR)
            log("Error: %s" % traceback.format_exc(), xbmc.LOGERROR)
            duration = 0

        log("Duration retrieved is = %d" % duration)

        return duration
Beispiel #4
0
 def __init__(self):
     self.networkList = []
     self.studioList = []
     self.mixedGenreList = []
     self.showGenreList = []
     self.movieGenreList = []
     self.showList = []
     self.channels = []
     self.videoParser = VideoParser()
     self.sleepTime = 0
     self.threadPaused = False
     self.runningActionChannel = 0
     self.runningActionId = 0
     self.enteredChannelCount = 0
     self.background = True
     random.seed()