def onClick(self, control): WINDOW_LIST_ID = 51 # Check to make sure that this click was for the extras list if control != WINDOW_LIST_ID: return # Check the YouTube Search first, as if there are no Extras on disk # There will not be a PlayAll button and it will just be the YouTube Link youtubePosition = 0 vimeoPosition = 0 if len(self.files) > 0: youtubePosition = youtubePosition + 1 vimeoPosition = vimeoPosition + 1 if Settings.isYouTubeSearchSupportEnabled(): vimeoPosition = vimeoPosition + 1 if self.getCurrentListPosition() == youtubePosition: anItem = self.getListItem(youtubePosition) searchDetails = anItem.getProperty("search") log("VideoExtras: Running YouTube Addon/Plugin with search %s" % searchDetails) xbmc.executebuiltin("RunAddon(plugin.video.youtube,%s)" % searchDetails) return if Settings.isVimeoSearchSupportEnabled() and self.getCurrentListPosition() == vimeoPosition: anItem = self.getListItem(vimeoPosition) searchDetails = anItem.getProperty("search") log("VideoExtras: Running Vimeo Addon/Plugin with search %s" % searchDetails) xbmc.executebuiltin("RunAddon(plugin.video.vimeo,%s)" % searchDetails) return # Check for the Play All case if self.getCurrentListPosition() == 0: ExtrasPlayer.playAll(self.files, SourceDetails.getTitle()) return # Get the item that was clicked on extraItem = self._getCurrentSelection() if extraItem is None: # Something has gone very wrong, there is no longer the item that was selected log("VideoExtrasWindow: Unable to match item to current selection") return # If part way viewed prompt the user for resume or play from beginning if extraItem.getResumePoint() > 0: resumeWindow = VideoExtrasResumeWindow.createVideoExtrasResumeWindow(extraItem.getDisplayResumePoint()) resumeWindow.doModal() # Check the return value, if exit, then we play nothing if resumeWindow.isExit(): return # If requested to restart from beginning, reset the resume point before playing if resumeWindow.isRestart(): extraItem.setResumePoint(0) # Default is to actually resume del resumeWindow ExtrasPlayer.performPlayAction(extraItem, SourceDetails.getTitle())
def playAllExtras(self, path, target, extrasParentTitle): # Check if the use database setting is enabled extrasDb = None if Settings.isDatabaseEnabled(): extrasDb = ExtrasDB() # Create the extras class that will be used to process the extras videoExtras = VideoExtrasBase(path, target, extrasParentTitle) # Perform the search command # No need for fanart default as only getting a list to play, not display files = videoExtras.findExtras(extrasDb=extrasDb) del videoExtras ExtrasPlayer.playAll(files, extrasParentTitle)
def showList(self, exList): # Get the list of display names displayNameList = [] for anExtra in exList: log("VideoExtrasDialog: filename: %s" % anExtra.getFilename()) displayNameList.append(anExtra.getDisplayName()) # Check if we are supporting YouTube Search vimeoPosition = -4 if Settings.isVimeoSearchSupportEnabled(): vimeoPosition = 0 displayNameList.insert(0, ADDON.getLocalizedString(32122)) # Check if we are supporting YouTube Search youtubePosition = -3 if Settings.isYouTubeSearchSupportEnabled(): youtubePosition = 0 vimeoPosition = vimeoPosition + 1 displayNameList.insert(0, ADDON.getLocalizedString(32116)) addPlayAll = (len(exList) > 1) if addPlayAll: youtubePosition = youtubePosition + 1 vimeoPosition = vimeoPosition + 1 # Play All Selection Option displayNameList.insert(0, ADDON.getLocalizedString(32101)) # Show the list to the user select = xbmcgui.Dialog().select(ADDON.getLocalizedString(32001), displayNameList) # User has made a selection, -1 is exit if select != -1: xbmc.executebuiltin("Dialog.Close(all, true)", True) waitLoop = 0 while xbmc.Player().isPlaying() and waitLoop < 10: xbmc.sleep(100) waitLoop = waitLoop + 1 xbmc.Player().stop() # Give anything that was already playing time to stop while xbmc.Player().isPlaying(): xbmc.sleep(100) if (select == 0) and (addPlayAll is True): ExtrasPlayer.playAll(exList, SourceDetails.getTitle()) elif select == youtubePosition: searchDetails = "/search/?q=%s+Extras" % urllib.quote_plus(SourceDetails.getTitle().encode('utf8')) log("VideoExtras: Running YouTube Addon/Plugin with search %s" % searchDetails) xbmc.executebuiltin("RunAddon(plugin.video.youtube,%s)" % searchDetails) elif select == vimeoPosition: searchDetails = "/search/?q=%s+Extras" % urllib.quote_plus(SourceDetails.getTitle().encode('utf8')) log("VideoExtras: Running Vimeo Addon/Plugin with search %s" % searchDetails) xbmc.executebuiltin("RunAddon(plugin.video.vimeo,%s)" % searchDetails) else: itemToPlay = select # If we added the PlayAll option to the list need to allow for it # in the selection, so add one if addPlayAll is True: itemToPlay = itemToPlay - 1 if vimeoPosition >= 0: itemToPlay = itemToPlay - 1 if youtubePosition >= 0: itemToPlay = itemToPlay - 1 log("VideoExtrasDialog: Start playing %s" % exList[itemToPlay].getFilename()) ExtrasPlayer.performPlayAction(exList[itemToPlay], SourceDetails.getTitle()) else: return False return True
def onClick(self, control): WINDOW_LIST_ID = 51 # Check to make sure that this click was for the extras list if control != WINDOW_LIST_ID: return # Check the YouTube Search first, as if there are no Extras on disk # There will not be a PlayAll button and it will just be the YouTube Link youtubePosition = 0 vimeoPosition = 0 if len(self.files) > 0: youtubePosition = youtubePosition + 1 vimeoPosition = vimeoPosition + 1 if Settings.isYouTubeSearchSupportEnabled(): vimeoPosition = vimeoPosition + 1 if self.getCurrentListPosition() == youtubePosition: anItem = self.getListItem(youtubePosition) searchDetails = anItem.getProperty("search") log("VideoExtras: Running YouTube Addon/Plugin with search %s" % searchDetails) xbmc.executebuiltin("RunAddon(plugin.video.youtube,%s)" % searchDetails) return if Settings.isVimeoSearchSupportEnabled( ) and self.getCurrentListPosition() == vimeoPosition: anItem = self.getListItem(vimeoPosition) searchDetails = anItem.getProperty("search") log("VideoExtras: Running Vimeo Addon/Plugin with search %s" % searchDetails) xbmc.executebuiltin("RunAddon(plugin.video.vimeo,%s)" % searchDetails) return # Check for the Play All case if self.getCurrentListPosition() == 0: ExtrasPlayer.playAll(self.files, SourceDetails.getTitle()) return # Get the item that was clicked on extraItem = self._getCurrentSelection() if extraItem is None: # Something has gone very wrong, there is no longer the item that was selected log("VideoExtrasWindow: Unable to match item to current selection") return # If part way viewed prompt the user for resume or play from beginning if extraItem.getResumePoint() > 0: resumeWindow = VideoExtrasResumeWindow.createVideoExtrasResumeWindow( extraItem.getDisplayResumePoint()) resumeWindow.doModal() # Check the return value, if exit, then we play nothing if resumeWindow.isExit(): return # If requested to restart from beginning, reset the resume point before playing if resumeWindow.isRestart(): extraItem.setResumePoint(0) # Default is to actually resume del resumeWindow ExtrasPlayer.performPlayAction(extraItem, SourceDetails.getTitle())
def showList(self, exList): # Get the list of display names displayNameList = [] for anExtra in exList: log("VideoExtrasDialog: filename: %s" % anExtra.getFilename()) displayNameList.append(anExtra.getDisplayName()) # Check if we are supporting YouTube Search vimeoPosition = -4 if Settings.isVimeoSearchSupportEnabled(): vimeoPosition = 0 displayNameList.insert(0, ADDON.getLocalizedString(32122)) # Check if we are supporting YouTube Search youtubePosition = -3 if Settings.isYouTubeSearchSupportEnabled(): youtubePosition = 0 vimeoPosition = vimeoPosition + 1 displayNameList.insert(0, ADDON.getLocalizedString(32116)) addPlayAll = (len(exList) > 1) if addPlayAll: youtubePosition = youtubePosition + 1 vimeoPosition = vimeoPosition + 1 # Play All Selection Option displayNameList.insert(0, ADDON.getLocalizedString(32101)) # Show the list to the user select = xbmcgui.Dialog().select(ADDON.getLocalizedString(32001), displayNameList) # User has made a selection, -1 is exit if select != -1: xbmc.executebuiltin("Dialog.Close(all, true)", True) waitLoop = 0 while xbmc.Player().isPlaying() and waitLoop < 10: xbmc.sleep(100) waitLoop = waitLoop + 1 xbmc.Player().stop() # Give anything that was already playing time to stop while xbmc.Player().isPlaying(): xbmc.sleep(100) if (select == 0) and (addPlayAll is True): ExtrasPlayer.playAll(exList, SourceDetails.getTitle()) elif select == youtubePosition: searchDetails = "/search/?q=%s+Extras" % urllib.quote_plus( SourceDetails.getTitle().encode('utf8')) log("VideoExtras: Running YouTube Addon/Plugin with search %s" % searchDetails) xbmc.executebuiltin("RunAddon(plugin.video.youtube,%s)" % searchDetails) elif select == vimeoPosition: searchDetails = "/search/?q=%s+Extras" % urllib.quote_plus( SourceDetails.getTitle().encode('utf8')) log("VideoExtras: Running Vimeo Addon/Plugin with search %s" % searchDetails) xbmc.executebuiltin("RunAddon(plugin.video.vimeo,%s)" % searchDetails) else: itemToPlay = select # If we added the PlayAll option to the list need to allow for it # in the selection, so add one if addPlayAll is True: itemToPlay = itemToPlay - 1 if vimeoPosition >= 0: itemToPlay = itemToPlay - 1 if youtubePosition >= 0: itemToPlay = itemToPlay - 1 log("VideoExtrasDialog: Start playing %s" % exList[itemToPlay].getFilename()) ExtrasPlayer.performPlayAction(exList[itemToPlay], SourceDetails.getTitle()) else: return False return True