Esempio n. 1
0
    def play_video(self, item, player=None):
        if isinstance(item, dict):
            item['info_type'] = 'video'

        item = self._listitemify(item)
        item.set_played(True)
        if player:
            _player = xbmc.Player(player)
        else:
            _player = xbmc.Player()
        _player.play(item.get_path(), item.as_xbmc_listitem())
        return [item]
Esempio n. 2
0
    def _add_subtitles(subtitles):
        """Adds subtitles to playing video.

        Warnings:
            You must start playing a video before calling this method or it
            will raise and Exception after 30 seconds.

        Args:
            subtitles (str): A URL to a remote subtitles file or a local
                filename for a subtitles file.
        """
        # This method is named with an underscore to suggest that callers pass
        # the subtitles argument to set_resolved_url instead of calling this
        # method directly. This is to ensure a video is played before calling
        # this method.
        player = xbmc.Player()
        monitor = xbmc.Monitor()
        while not monitor.abortRequested():
            if monitor.waitForAbort(30):
                # Abort requested, so exit.
                break
            elif player.isPlaying():
                # No abort requested after 30 seconds and a video is playing
                # so add the subtitles and exit.
                player.setSubtitles(subtitles)
                break
            else:
                raise Exception('No video playing. Aborted after 30 seconds.')