def resolve_url(self, stream_url): ''' Tell XBMC that you have resolved a URL (or not!). This method should be called as follows: #. The user selects a list item that has previously had ``isPlayable`` set (this is true for items added with :meth:`add_item`, :meth:`add_music_item` or :meth:`add_music_item`) #. Your code resolves the item requested by the user to a media URL #. Your addon calls this method with the resolved URL Args: stream_url (str or ``False``): If a string, tell XBMC that the media URL ha been successfully resolved to stream_url. If ``False`` or an empty string tell XBMC the resolving failed and pop up an error messsage. ''' if stream_url: self.log_debug('resolved to: %s' % stream_url) xbmcplugin.setResolvedUrl(self.handle, True, xbmcgui.ListItem(path=stream_url)) else: self.show_error_dialog(['sorry, failed to resolve URL :(']) xbmcplugin.setResolvedUrl(self.handle, False, xbmcgui.ListItem())
def play(artist, track): data = getTrack(artist, track) print data item = ListItem() item.set_label('%s - %s' % (artist, track)) item.set_path(data['url']) item.set_played(True) xbmcplugin.setResolvedUrl(plugin.handle, True, item.as_xbmc_listitem())
def play_video(video_id): log("play_video") video_url, video_title, img_id = fetch_cached_video_info(video_id) img_src = get_img_src(img_id) listitem = xbmcgui.ListItem(label="title", iconImage='', thumbnailImage=img_src, path=video_url) #log("Playing video: " + video_id + " - " + video_url + " - " + img_src) xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=listitem)
def set_resolved_url(self, item=None, subtitles=None): '''Takes a url or a listitem to be played. Used in conjunction with a playable list item with a path that calls back into your addon. :param item: A playable list item or url. Pass None to alert XBMC of a failure to resolve the item. .. warning:: When using set_resolved_url you should ensure the initial playable item (which calls back into your addon) doesn't have a trailing slash in the URL. Otherwise it won't work reliably with KODI's PlayMedia(). :param subtitles: A URL to a remote subtitles file or a local filename for a subtitles file to be played along with the item. ''' if self._end_of_directory: raise Exception('Current XBMC handle has been removed. Either ' 'set_resolved_url(), end_of_directory(), or ' 'finish() has already been called.') self._end_of_directory = True succeeded = True if item is None: # None item indicates the resolve url failed. item = {} succeeded = False # caller is passing a url instead of an item dict if PY3 and (isinstance(item, bytes) or isinstance(item, str)): item = {'path': item} elif not PY3 and isinstance(item, basestring): item = {'path': item} item = self._listitemify(item) item.set_played(True) xbmcplugin.setResolvedUrl(self.handle, succeeded, item.as_xbmc_listitem()) # call to _add_subtitles must be after setResolvedUrl if subtitles: self._add_subtitles(subtitles) return [item]
def set_resolved_url(self, item=None, subtitles=None): '''Takes a url or a listitem to be played. Used in conjunction with a playable list item with a path that calls back into your addon. :param item: A playable list item or url. Pass None to alert XBMC of a failure to resolve the item. .. warning:: When using set_resolved_url you should ensure the initial playable item (which calls back into your addon) doesn't have a trailing slash in the URL. Otherwise it won't work reliably with XBMC's PlayMedia(). :param subtitles: A URL to a remote subtitles file or a local filename for a subtitles file to be played along with the item. ''' if self._end_of_directory: raise Exception('Current XBMC handle has been removed. Either ' 'set_resolved_url(), end_of_directory(), or ' 'finish() has already been called.') self._end_of_directory = True succeeded = True if item is None: # None item indicates the resolve url failed. item = {} succeeded = False if isinstance(item, basestring): # caller is passing a url instead of an item dict item = {'path': item} item = self._listitemify(item) item.set_played(True) xbmcplugin.setResolvedUrl(self.handle, succeeded, item.as_xbmc_listitem()) # call to _add_subtitles must be after setResolvedUrl if subtitles: self._add_subtitles(subtitles) return [item]
def set_resolved_url(self, url): item = xbmcswift2.ListItem(path=url) item.set_played(True) xbmcplugin.setResolvedUrl(self.handle, True, item.as_xbmc_listitem()) return [item]