예제 #1
0
    def subtitleButtonClicked(self):
        options = []

        options.append({'key': 'download', 'display': T(32405, 'Download Subtitles')})
        if xbmc.getCondVisibility('VideoPlayer.HasSubtitles'):
            if xbmc.getCondVisibility('VideoPlayer.SubtitlesEnabled'):
                options.append({'key': 'delay', 'display': T(32406, 'Subtitle Delay')})
                options.append({'key': 'cycle', 'display': T(32407, 'Next Subtitle')})
            options.append(
                {
                    'key': 'enable',
                    'display': xbmc.getCondVisibility(
                        'VideoPlayer.SubtitlesEnabled + VideoPlayer.HasSubtitles'
                    ) and T(32408, 'Disable Subtitles') or T(32409, 'Enable Subtitles')
                }
            )

        choice = dropdown.showDropdown(options, (1360, 1060), close_direction='down', pos_is_bottom=True, close_on_playback_ended=True)

        if not choice:
            return

        if choice['key'] == 'download':
            self.hideOSD()
            builtin.ActivateWindow('SubtitleSearch')
        elif choice['key'] == 'delay':
            self.hideOSD()
            builtin.Action('SubtitleDelay')
        elif choice['key'] == 'cycle':
            builtin.Action('CycleSubtitle')
        elif choice['key'] == 'enable':
            builtin.Action('ShowSubtitles')
예제 #2
0
    def onAction(self, action):
        if xbmc.getCondVisibility('Window.IsActive(selectdialog)'):
            if self.doKodiSelectDialogHack(action):
                return

        try:
            self.resetTimeout()

            controlID = self.getFocusId()
            if action.getId() in KEY_MOVE_SET:
                self.setProperty('mouse.mode', '')

            elif action == xbmcgui.ACTION_MOUSE_MOVE:
                self.setProperty('mouse.mode', '1')

            if controlID in (self.MAIN_BUTTON_ID, self.NO_OSD_BUTTON_ID):
                if action == xbmcgui.ACTION_MOUSE_LEFT_CLICK:
                    if self.getProperty('mouse.mode') != '1':
                        self.setProperty('mouse.mode', '1')

                    self.seekMouse(
                        action, without_osd=controlID == self.NO_OSD_BUTTON_ID)
                    return
                elif action == xbmcgui.ACTION_MOUSE_MOVE:
                    self.seekMouse(
                        action,
                        without_osd=controlID == self.NO_OSD_BUTTON_ID,
                        preview=True)
                    return

            if controlID == self.MAIN_BUTTON_ID:
                # we're seeking from the timeline with the OSD open - do an actual timeline seek
                if not self._seeking and action.getId() in KEY_STEP_SEEK_SET:
                    self.selectedOffset = self.trueOffset()

                if action in (xbmcgui.ACTION_MOVE_RIGHT,
                              xbmcgui.ACTION_STEP_FORWARD):
                    if self.useDynamicStepsForTimeline:
                        return self.skipForward()
                    return self.seekByOffset(10000, auto_seek=self.useAutoSeek)

                elif action in (xbmcgui.ACTION_MOVE_LEFT,
                                xbmcgui.ACTION_STEP_BACK):
                    if self.useDynamicStepsForTimeline:
                        return self.skipBack()
                    return self.seekByOffset(-10000,
                                             auto_seek=self.useAutoSeek)

                elif action == xbmcgui.ACTION_MOVE_DOWN:
                    self.updateBigSeek()
                # elif action == xbmcgui.ACTION_MOVE_UP:
                #     self.seekForward(60000)
                # elif action == xbmcgui.ACTION_MOVE_DOWN:
                #     self.seekBack(60000)

            # don't auto-apply the currently selected seek when pressing down
            elif controlID == self.PLAY_PAUSE_BUTTON_ID and self.previousFocusID == self.MAIN_BUTTON_ID \
                    and action == xbmcgui.ACTION_MOVE_DOWN:
                self.resetSeeking()

            elif controlID == self.NO_OSD_BUTTON_ID:
                if action in (xbmcgui.ACTION_MOVE_RIGHT,
                              xbmcgui.ACTION_MOVE_LEFT):
                    # we're seeking from the timeline, with the OSD closed; act as we're skipping
                    if not self._seeking:
                        self.selectedOffset = self.trueOffset()

                    if action == xbmcgui.ACTION_MOVE_RIGHT:
                        self.skipForward(without_osd=True)

                    else:
                        self.skipBack(without_osd=True)
                if action in (xbmcgui.ACTION_MOVE_UP, xbmcgui.ACTION_MOVE_DOWN,
                              xbmcgui.ACTION_BIG_STEP_FORWARD,
                              xbmcgui.ACTION_BIG_STEP_BACK
                              ) and not self._seekingWithoutOSD:
                    self.selectedOffset = self.trueOffset()
                    self.setBigSeekShift()
                    self.updateProgress()
                    self.showOSD()
                    self.setFocusId(self.BIG_SEEK_LIST_ID)
                elif action.getButtonCode() == 61519:
                    # xbmc.executebuiltin('Action(PlayerProcessInfo)')
                    xbmc.executebuiltin('Action(CodecInfo)')
            elif controlID == self.BIG_SEEK_LIST_ID:
                if action in (xbmcgui.ACTION_MOVE_RIGHT,
                              xbmcgui.ACTION_BIG_STEP_FORWARD):
                    return self.updateBigSeek(changed=True)
                elif action in (xbmcgui.ACTION_MOVE_LEFT,
                                xbmcgui.ACTION_BIG_STEP_BACK):
                    return self.updateBigSeek(changed=True)

            if action.getButtonCode() == 61516:
                builtin.Action('CycleSubtitle')
            elif action.getButtonCode() == 61524:
                builtin.Action('ShowSubtitles')
            elif action == xbmcgui.ACTION_NEXT_ITEM:
                next(self.handler)
            elif action == xbmcgui.ACTION_PREV_ITEM:
                self.handler.prev()
            elif action in (xbmcgui.ACTION_PREVIOUS_MENU,
                            xbmcgui.ACTION_NAV_BACK, xbmcgui.ACTION_STOP):
                if self._seeking:
                    self.resetSeeking()
                    self.updateCurrent()
                    self.updateProgress()
                    if self.osdVisible():
                        self.hideOSD()
                    return

                if action in (xbmcgui.ACTION_PREVIOUS_MENU,
                              xbmcgui.ACTION_NAV_BACK):
                    if self._osdHideAnimationTimeout:
                        if self._osdHideAnimationTimeout >= time.time():
                            return
                        else:
                            self._osdHideAnimationTimeout = None

                    if self.osdVisible():
                        self.hideOSD()
                    else:
                        self.doClose()
                        # self.handler.onSeekAborted()
                        self.handler.player.stop()
                    return
        except:
            util.ERROR()

        kodigui.BaseDialog.onAction(self, action)
예제 #3
0
    def onAction(self, action):
        try:
            # util.TEST((action.getId(), action.getButtonCode(), action.getAmount1(), action.getAmount2()))
            self.resetTimeout()

            controlID = self.getFocusId()
            if action.getId() in KEY_MOVE_SET:
                self.setProperty('mouse.mode', '')
                if not controlID:
                    self.setBigSeekShift()
                    self.setFocusId(400)
                    return
            elif action == xbmcgui.ACTION_MOUSE_MOVE:
                self.setProperty('mouse.mode', '1')

            if controlID == self.MAIN_BUTTON_ID:
                if action == xbmcgui.ACTION_MOUSE_MOVE:
                    return self.seekMouse(action)
                elif action in (xbmcgui.ACTION_MOVE_RIGHT,
                                xbmcgui.ACTION_NEXT_ITEM):
                    return self.seekForward(10000)
                elif action in (xbmcgui.ACTION_MOVE_LEFT,
                                xbmcgui.ACTION_PREV_ITEM):
                    return self.seekBack(10000)
                elif action == xbmcgui.ACTION_MOVE_DOWN:
                    self.updateBigSeek()
                # elif action == xbmcgui.ACTION_MOVE_UP:
                #     self.seekForward(60000)
                # elif action == xbmcgui.ACTION_MOVE_DOWN:
                #     self.seekBack(60000)
            elif controlID == self.NO_OSD_BUTTON_ID:
                if action in (xbmcgui.ACTION_MOVE_RIGHT,
                              xbmcgui.ACTION_MOVE_LEFT):
                    self.showOSD()
                    self.setFocusId(self.MAIN_BUTTON_ID)
                elif action in (xbmcgui.ACTION_MOVE_UP,
                                xbmcgui.ACTION_MOVE_DOWN):
                    self.selectedOffset = self.trueOffset()
                    self.setBigSeekShift()
                    self.updateProgress()
                    self.showOSD()
                    self.setFocusId(self.BIG_SEEK_LIST_ID)
                elif action.getButtonCode() == 61519:
                    # xbmc.executebuiltin('Action(PlayerProcessInfo)')
                    xbmc.executebuiltin('Action(CodecInfo)')
            elif controlID == self.BIG_SEEK_LIST_ID:
                if action in (xbmcgui.ACTION_MOVE_RIGHT,
                              xbmcgui.ACTION_NEXT_ITEM):
                    return self.updateBigSeek()
                elif action in (xbmcgui.ACTION_MOVE_LEFT,
                                xbmcgui.ACTION_PREV_ITEM):
                    return self.updateBigSeek()

            if action.getButtonCode() == 61516:
                builtin.Action('CycleSubtitle')
            elif action.getButtonCode() == 61524:
                builtin.Action('ShowSubtitles')
            elif action in (xbmcgui.ACTION_PREVIOUS_MENU,
                            xbmcgui.ACTION_NAV_BACK):
                if self.osdVisible():
                    self.hideOSD()
                else:
                    self.doClose()
                    # self.handler.onSeekAborted()
                    self.handler.player.stop()
                return
        except:
            util.ERROR()

        kodigui.BaseDialog.onAction(self, action)