def show_dialog(title, message): """ Shows a dialog box with title and text :param str|None|int title: The title of the box or its language ID. :param str|int message: The lines to display or its language ID. :return: True for OK, False for cancelled. :rtype: bool """ if isinstance(title, int): title = LanguageHelper.get_localized_string(title) if isinstance(message, int): message = LanguageHelper.get_localized_string(message) # let's just unlock the interface, in case it's locked. LockWithDialog.close_busy_dialog() msg_box = xbmcgui.Dialog() if not title: header = Config.appName else: header = "%s - %s" % (Config.appName, title) ok = msg_box.ok(header, message or "") return ok
def show_yes_no(title, message): """ Shows a dialog yes/no box with title and text :param str|int title: The title of the box or its language ID. :param str|int message: The message to display or its language ID. :return: Ok or not OK (boolean) :rtype: bool """ if isinstance(title, int): title = LanguageHelper.get_localized_string(title) if isinstance(message, int): message = LanguageHelper.get_localized_string(message) # let's just unlock the interface, in case it's locked. LockWithDialog.close_busy_dialog() msg_box = xbmcgui.Dialog() if title == "": header = Config.appName else: header = "%s - %s" % (Config.appName, title) ok = msg_box.yesno(header, message or "") return ok
def show_dialog(title, lines): """ Shows a dialog box with title and text :param str|None title: The title of the box :param list[str]|str lines: The lines to display. :return: True for OK, False for cancelled. :rtype: bool """ # let's just unlock the interface, in case it's locked. LockWithDialog.close_busy_dialog() msg_box = xbmcgui.Dialog() if title == "": header = Config.appName else: header = "%s - %s" % (Config.appName, title) if len(lines) == 0: ok = msg_box.ok(header, "") elif isinstance(lines, basestring): # it was just a string, no list or tuple ok = msg_box.ok(header, lines) elif len(lines) == 1: ok = msg_box.ok(header, lines[0]) elif len(lines) == 2: ok = msg_box.ok(header, lines[0], lines[1]) else: ok = msg_box.ok(header, lines[0], lines[1], lines[2]) return ok
def show_yes_no(title, lines): """ Shows a dialog yes/no box with title and text :param str title: The title of the box. :param list[str] lines: The lines to display. :return: Ok or not OK (boolean) :rtype: bool """ # let's just unlock the interface, in case it's locked. LockWithDialog.close_busy_dialog() msg_box = xbmcgui.Dialog() if title == "": header = Config.appName else: header = "%s - %s" % (Config.appName, title) if len(lines) == 0: ok = msg_box.yesno(header, "") elif isinstance(lines, basestring): # it was just a string, no list or tuple ok = msg_box.yesno(header, lines) else: ok = False return ok
def show_key_board(default="", heading="", hidden=False): """ Displays the Kodi keyboard. :param str default: The default value :param str heading: The heading for the dialog :param bool hidden: Should the input be hidden? :rtype: str :return: returns the text that was entered or None if cancelled. """ # let's just unlock the interface, in case it's locked. LockWithDialog.close_busy_dialog() keyboard = xbmc.Keyboard(default, heading, hidden) keyboard.doModal() if not keyboard.isConfirmed(): return None return keyboard.getText()
def play_video_item(self): """ Starts the videoitem using a playlist. """ from resources.lib import player Logger.debug("Playing videoitem using PlayListMethod") try: media_item = self.media_item if not media_item.complete: media_item = self.channelObject.process_video_item(media_item) # Any warning to show self.__show_warnings(media_item) # validated the updated media_item if not media_item.complete or not media_item.has_media_item_parts( ): Logger.warning( "process_video_item returned an MediaItem that had MediaItem.complete = False:\n%s", media_item) if not media_item.has_media_item_parts(): # the update failed or no items where found. Don't play XbmcWrapper.show_notification( LanguageHelper.get_localized_string( LanguageHelper.ErrorId), LanguageHelper.get_localized_string( LanguageHelper.NoStreamsId), XbmcWrapper.Error) Logger.warning( "Could not start playback due to missing streams. Item:\n%s", media_item) xbmcplugin.endOfDirectory(self.handle, False) return kodi_items = media_item.get_kodi_play_list_data( AddonSettings.get_max_stream_bitrate(self.channelObject), self.channelObject.proxy) Logger.debug("Continuing playback in plugin.py") if not bool(kodi_items): Logger.warning("play_video_item did not return valid playdata") xbmcplugin.endOfDirectory(self.handle, False) return # Now we force the busy dialog to close, else the video will not play and the # setResolved will not work. LockWithDialog.close_busy_dialog() # Append it to the Kodi playlist in a smart way. start_url = self.__append_kodi_play_list(kodi_items) # Set the mode (if the InputStream Adaptive add-on is used, we also need to set it) show_subs = AddonSettings.show_subtitles() # TODO: Apparently if we use the InputStream Adaptive, using the setSubtitles() causes sync issues. available_subs = [p.Subtitle for p in media_item.MediaItemParts] # Get the Kodi Player instance (let Kodi decide what player, see # http://forum.kodi.tv/showthread.php?tid=173887&pid=1516662#pid1516662) kodi_player = player.Player(show_subs=show_subs, subs=available_subs) kodi_player.waitForPlayBack(url=start_url, time_out=10) xbmcplugin.endOfDirectory(self.handle, True) except: XbmcWrapper.show_notification( LanguageHelper.get_localized_string(LanguageHelper.ErrorId), LanguageHelper.get_localized_string( LanguageHelper.NoPlaybackId), XbmcWrapper.Error) Logger.critical("Could not playback the url", exc_info=True) # We need to single Kodi that it failed and it should not wait longer. Either using a # `raise` or with `xbmcplugin.endOfDirectory`. Doing the latter for now although we are # not really playing. xbmcplugin.endOfDirectory(self.handle, False) return