Exemple #1
0
    def _event_handler(self, event):
        logger.log(
            9,
            '_event_handler(event=%s), event.arg=%r, event.context=%r, PluginInterface.detached=%r',
            event, event.arg, event.context, PluginInterface.detached)

        player = audio.player.get()

        if plugin.isevent(event) == 'DETACH':
            PluginInterface.detached = True
            self.update(DIALOG_SHOW)
        elif plugin.isevent(event) == 'ATTACH':
            PluginInterface.detached = False
            self.update(DIALOG_HIDE)
        elif event == BUTTON and event.arg == 'STOP':
            PluginInterface.detached = False
            self.update(DIALOG_HIDE)
        elif PluginInterface.detached:
            # this event can only happen if video or game starts playing
            # hide the dialog now
            if event == VIDEO_START:
                PluginInterface.detached = False
                self.update(DIALOG_HIDE)
            elif event == PLAY_START and not player.visible:
                self.update(DIALOG_SHOW)
Exemple #2
0
 def _event_handler(self, event):
     logger.log(9, '_event_handler(event=%s), event.arg=%r, event.context=%r, PluginInterface.detached=%r', 
         event, event.arg, event.context, PluginInterface.detached)
     gui = audio.player.get()
     if gui:
         p = gui.player
         if event == BUTTON:
             if event.arg == 'FFWD':
                 p.eventhandler(Event('SEEK', arg='10', context='audio'))
             elif event.arg == 'REW':
                 p.eventhandler(Event('SEEK', arg='-10', context='audio'))
             elif event.arg == 'PAUSE':
                 p.eventhandler(Event('PLAY', context='audio'))
             elif event.arg == 'STOP':
                 PluginInterface.detached = False
                 p.eventhandler(Event('STOP'))
             elif event.arg == 'NEXT':
                 p.eventhandler(Event('PLAYLIST_NEXT', context='audio'))
             elif event.arg == 'PREV':
                 p.eventhandler(Event('PLAYLIST_PREV', context='audio'))
         elif plugin.isevent(event) == 'DETACH':
             p.eventhandler(event)
             self._detach()
         elif plugin.isevent(event) == 'ATTACH':
             self._attach()
             p.eventhandler(event)
         elif event == VIDEO_START:
             PluginInterface.detached = False
             p.eventhandler(Event('STOP'))
         elif event == PLAY_START and gui.visible:
             rc.post_event(plugin.event('ATTACH'))
    def eventhandler(self, event=None, menuw=None, arg=None):
        """
        eventhandler to handle the events. Always return false since we
        are just a listener and really can't send back true.
        """
        logger.log( 9, 'Saver saw %s', event.name)
        if menuw:
            self.menuw = menuw

        if event.name == 'SCREENSAVER_START':
            self.start_saver()
            return FALSE

        if event.name == 'SCREENSAVER_STOP' and self.screensaver_showing :
            self.stop_saver()
            return FALSE

        # gotta ignore these or video screensavers shutoff before they begin
        if event.name == 'VIDEO_START' or event.name == 'PLAY_START' or \
            event.name == 'VIDEO_END' or event.name == 'PLAY_END':
            return FALSE

        if self.screensaver_showing :
            self.stop_saver()

        if plugin.isevent(event) != 'IDENTIFY_MEDIA':
            self.last_event = time.time()

        return FALSE
    def eventhandler(self, event=None, menuw=None, arg=None):
        """
        eventhandler to handle the events. Always return false since we
        are just a listener and really can't send back true.
        """
        _debug_('Saver saw %s' % (event.name), 2)
        if menuw:
            self.menuw = menuw

        if event.name == 'SCREENSAVER_START':
            self.start_saver()
            return FALSE

        if event.name == 'SCREENSAVER_STOP' and self.screensaver_showing :
            self.stop_saver()
            return FALSE

        # gotta ignore these or video screensavers shutoff before they begin
        if event.name == 'VIDEO_START' or event.name == 'PLAY_START' or \
            event.name == 'VIDEO_END' or event.name == 'PLAY_END':
            return FALSE

        if self.screensaver_showing :
            self.stop_saver()

        if plugin.isevent(event) != 'IDENTIFY_MEDIA':
            self.last_event = time.time()

        return FALSE
Exemple #5
0
    def eventhandler(self, event=None, menuw=None):
        """
        eventhandler for the main menu. The menu must be regenerated
        when a disc in a rom drive changes
        """
        if plugin.isevent(event):
            if not menuw:
                menuw = self.menuw

            menu = menuw.menustack[1]

            sel = menu.choices.index(menu.selected)
            menuw.menustack[1].choices = self.main_menu_generate()
            if not menu.selected in menu.choices:
                if len( menu.choices ) > sel:
                    menu.selected = menu.choices[sel]
                elif menu.choices:
                    menu.selected = menu.choices[ -1 ]
                else:
                    menu.selected = None

            if menu == menuw.menustack[-1] and rc.focused_app() == menuw:
                menuw.init_page()
                menuw.refresh()
            # others may need this event, too
            return False

        if event in (PLAY_END, USER_END, STOP) and event.context != 'menu':
            if menuw:
                menuw.show()
            return True

        # give the event to the next eventhandler in the list
        return Item.eventhandler(self, event, menuw)
Exemple #6
0
 def eventhandler(self, event=None, menuw=None, arg=None):
     logger.log( 9, 'eventhandler(event=%r, menuw=%r, arg=%r)', event, menuw, arg)
     if not self.lock:
         if plugin.isevent(event) != 'IDENTIFY_MEDIA' and event.name != 'SCREENSAVER_START':
             self.reset()
             logger.log( 9, 'timer reset, received event %s', event.name)
     return FALSE
Exemple #7
0
 def eventhandler(self, event, menuw=None):
     """
     Needed to catch the plugin DETACH event
     """
     if plugin.isevent(event) == 'DETACH':
         self.show()
         return True
     return False
Exemple #8
0
 def eventhandler(self, event, menuw=None):
     """
     catch the IDENTIFY_MEDIA event to redraw the skin (maybe the cd status
     plugin wants to redraw)
     """
     if plugin.isevent(event) == 'IDENTIFY_MEDIA' and skin.active():
         skin.redraw()
     return False
Exemple #9
0
 def eventhandler(self, event, menuw=None):
     """
     catch the IDENTIFY_MEDIA event to redraw the skin (maybe the cd status
     plugin wants to redraw)
     """
     logger.log( 9, 'PluginInterface.eventhandler(event=%r, menuw=%r)', event, menuw)
     if skin.active() and plugin.isevent(event) == 'IDENTIFY_MEDIA':
         skin.redraw()
     return False
Exemple #10
0
 def eventhandler(self, event=None, menuw=None, arg=None):
     logger.log(9, 'eventhandler(event=%r, menuw=%r, arg=%r)', event, menuw,
                arg)
     if not self.lock:
         if plugin.isevent(
                 event
         ) != 'IDENTIFY_MEDIA' and event.name != 'SCREENSAVER_START':
             self.reset()
             logger.log(9, 'timer reset, received event %s', event.name)
     return FALSE
Exemple #11
0
 def _event_handler(self, event):
     logger.log( 9, '_event_handler(event=%s)', event)
     if plugin.isevent(event) == 'DETACH':
         PluginInterface.detached = True
         self.update(BAR_SHOW)
     elif plugin.isevent(event) == 'ATTACH':
         PluginInterface.detached = False
         self.update(BAR_HIDE)
     elif event == STOP:
         PluginInterface.detached = False
         self.update(BAR_HIDE)
     elif event == BUTTON and event.arg == 'STOP':
         PluginInterface.detached = False
         self.update(BAR_HIDE)
     elif PluginInterface.detached:
         if event == PLAY_START:
             self.update(BAR_SHOW)
         elif event == PLAY_END:
             self.update(BAR_WAIT)
Exemple #12
0
 def eventhandler(self, event, menuw=None):
     """
     catch the IDENTIFY_MEDIA event to redraw the skin (maybe the cd status
     plugin wants to redraw)
     """
     logger.log(9, 'PluginInterface.eventhandler(event=%r, menuw=%r)',
                event, menuw)
     if skin.active() and plugin.isevent(event) == 'IDENTIFY_MEDIA':
         skin.redraw()
     return False
Exemple #13
0
 def _event_handler(self, event):
     logger.log(9, '_event_handler(event=%s)', event)
     if plugin.isevent(event) == 'DETACH':
         PluginInterface.detached = True
         self.update(BAR_SHOW)
     elif plugin.isevent(event) == 'ATTACH':
         PluginInterface.detached = False
         self.update(BAR_HIDE)
     elif event == STOP:
         PluginInterface.detached = False
         self.update(BAR_HIDE)
     elif event == BUTTON and event.arg == 'STOP':
         PluginInterface.detached = False
         self.update(BAR_HIDE)
     elif PluginInterface.detached:
         if event == PLAY_START:
             self.update(BAR_SHOW)
         elif event == PLAY_END:
             self.update(BAR_WAIT)
Exemple #14
0
 def eventhandler(self, event=None, menuw=None, arg=None):
     if plugin.isevent(event) == 'UVSWITCH':
         active = event.arg and self.channel in event.arg
         if active and not self.active:
             # Our input has just been enabled, add a menu item
             self.addItem(menuw, VideoInputItem(self))
         elif not active and self.active:
             # Out input has been disabled
             self.removeItems(menuw)
         self.active = active
Exemple #15
0
 def _event_handler(self, event):
     logger.log(9, '_event_handler(event=%s), event.arg=%r, event.context=%r, PluginInterface.detached=%r', 
         event, event.arg, event.context, PluginInterface.detached)
     
     player = audio.player.get()
     
     if plugin.isevent(event) == 'DETACH':
         PluginInterface.detached = True
         self.update(DIALOG_SHOW)
     elif plugin.isevent(event) == 'ATTACH':
         PluginInterface.detached = False
         self.update(DIALOG_HIDE)
     elif event == BUTTON and event.arg == 'STOP':
         PluginInterface.detached = False
         self.update(DIALOG_HIDE)
     elif PluginInterface.detached:
         # this event can only happen if video or game starts playing
         # hide the dialog now
         if event == VIDEO_START:
             PluginInterface.detached = False
             self.update(DIALOG_HIDE)
         elif event == PLAY_START and not player.visible:
             self.update(DIALOG_SHOW)
Exemple #16
0
    def eventhandler(self, event=None, menuw=None, arg=None):
        """
        eventhandler to handle the IDENTIFY_MEDIA plugin event and the
        EJECT event
        """
        global im_thread

        # if we are at the main menu and there is an IDENTIFY_MEDIA event,
        # try to autorun the media
        if plugin.isevent(event) == 'IDENTIFY_MEDIA':
            (media, state) = event.arg
            if not menuw:
                return False
            if len(menuw.menustack) != 1:
                return False
            if state != CDS_DISC_OK:
                return False

            if media.item:
                media.item.parent = menuw.menustack[0].selected
            if media.item and media.item.actions():
                if media.type == 'audio':
                    # disc marked as audio, play everything
                    if media.item.type == 'dir':
                        media.item.play_recursive(menuw=menuw)
                    elif media.item.type == 'audiocd':
                        media.item.play(menuw=menuw)
                    else:
                        media.item.actions()[0][0](menuw=menuw)
                elif media.videoitem:
                    # disc has one video file, play it
                    media.videoitem.actions()[0][0](menuw=menuw)
                else:
                    # ok, do whatever this item has to offer
                    media.item.actions()[0][0](menuw=menuw)
            else:
                menuw.refresh()
            return True

        # Handle the EJECT key for the main menu
        elif event == EJECT and len(menuw.menustack) == 1:

            # Are there any drives defined?
            if config.REMOVABLE_MEDIA:
                # The default is the first drive in the list
                media = config.REMOVABLE_MEDIA[0]
                media.move_tray(direction='toggle')
                return True
Exemple #17
0
    def eventhandler(self, event=None, menuw=None, arg=None):
        """
        eventhandler to handle the IDENTIFY_MEDIA plugin event and the
        EJECT event
        """
        global im_thread

        # if we are at the main menu and there is an IDENTIFY_MEDIA event,
        # try to autorun the media
        if plugin.isevent(event) == 'IDENTIFY_MEDIA':
            (media, state) = event.arg
            if not menuw:
                return False
            if len(menuw.menustack) != 1:
                return False
            if state != CDS_DISC_OK:
                return False

            if media.item:
                media.item.parent = menuw.menustack[0].selected
            if media.item and media.item.actions():
                if media.type == 'audio':
                    # disc marked as audio, play everything
                    if media.item.type == 'dir':
                        media.item.play_recursive(menuw=menuw)
                    elif media.item.type == 'audiocd':
                        media.item.play(menuw=menuw)
                    else:
                        media.item.actions()[0][0](menuw=menuw)
                elif media.videoitem:
                    # disc has one video file, play it
                    media.videoitem.actions()[0][0](menuw=menuw)
                else:
                    # ok, do whatever this item has to offer
                    media.item.actions()[0][0](menuw=menuw)
            else:
                menuw.refresh()
            return True

        # Handle the EJECT key for the main menu
        elif event == EJECT and len(menuw.menustack) == 1:

            # Are there any drives defined?
            if config.REMOVABLE_MEDIA:
                # The default is the first drive in the list
                media = config.REMOVABLE_MEDIA[0]
                media.move_tray(direction='toggle')
                return True
Exemple #18
0
    def eventhandler(self, event=None, menuw=None, arg=None):
        """
        eventhandler to handle the events. Always return False since we
        are just a listener and really can't send back True.
        """
        logger.log( 9, 'eventhandler(event=%r, menuw=%r, arg=%r)', event.name, menuw, arg)
        if menuw:
            self.menuw = menuw

        if plugin.isevent(event) != 'IDENTIFY_MEDIA':
            self.start_timer.start(self.start_delay)

        if self.screensaver_showing:
            self.stop_saver()
            return True

        return False
Exemple #19
0
    def eventhandler(self, event=None, arg=None):
        """
        eventhandler to simulate hide/show of mpav
        """
        logger.debug('mplayervis1.eventhandler(event=%r, arg=%r)', event.name, arg)
        print('mplayervis1.eventhandler(event=%r, arg=%r)' % (event.name, arg))

        if plugin.isevent(event) == 'DETACH':
            PluginInterface.detached = True
            self.stop_visual()

        elif plugin.isevent(event) == 'ATTACH':
            PluginInterface.detached = False
            self.start_visual()

        elif event == PLAY_START:
            if self.player.playerGUI.succession == PlayListSuccession.FIRST:
                self.start_visual()
            else:
                self.resume_visual()
            self.message = self.item_info(self.message_fmt)
            if self.mpvgoom is not None:
                self.mpvgoom.message = self.message
            print('%s.message=%r' % (self.__class__, self.message))

        elif event == PLAY_END:
            if self.player.playerGUI.succession == PlayListSuccession.LAST:
                self.stop_visual()
            else:
                self.pause_visual()

        elif event == STOP:
            PluginInterface.detached = False
            self.stop_visual()

        elif event == 'CHANGE_MODE':
            self.toggle_view()
            return True

        elif event == 'DISPLAY_FPS':
            if self.mpvgoom is not None:
                self.mpvgoom.showfps = not self.mpvgoom.showfps
            logger.debug('showfps=%s', self.mpvgoom.showfps)
            return True

        elif event == 'DISPLAY_TITLE':
            if not self.title:
                self.title = self.item_info('%(t)s')
            logger.debug('title=%s', self.title)
            if self.mpvgoom is not None:
                self.mpvgoom.set_songtitle(self.title)
            return True

        elif event == 'DISPLAY_MESSAGE':
            #self.message = not self.message and self.item_info(self.message_fmt) or ''
            if not self.message:
                self.message = self.item_info(self.message_fmt)
            logger.debug('message=%r', self.message)
            if self.mpvgoom is not None:
                self.mpvgoom.set_message(self.message)
            return True

        elif event == 'NEXT_VISUAL':
            PluginInterface.vis_mode += 1
            if PluginInterface.vis_mode > 9: PluginInterface.vis_mode = -1
            logger.debug('vis_mode=%s', PluginInterface.vis_mode)
            if self.mpvgoom is not None:
                self.mpvgoom.set_visual(PluginInterface.vis_mode)
                rc.post_event(Event(OSD_MESSAGE, arg=_('FXMODE is %s' % PluginInterface.vis_mode)))
            return True

        elif event == 'CHANGE_VISUAL':
            PluginInterface.vis_mode = event.arg
            if PluginInterface.vis_mode < -1: PluginInterface.vis_mode = -1
            if PluginInterface.vis_mode > 9: PluginInterface.vis_mode = 9
            logger.debug('vis_mode=%s', PluginInterface.vis_mode)
            if self.mpvgoom is not None:
                self.mpvgoom.set_visual(PluginInterface.vis_mode)
                rc.post_event(Event(OSD_MESSAGE, arg=_('FXMODE is %s' % PluginInterface.vis_mode)))
            return True

        elif event == OSD_MESSAGE:
            if self.mpvgoom is not None: # and self.view == MpvMode.FULL:
                self.mpvgoom.set_info(event.arg)
                return True

        if self.passed_event:
            self.passed_event = False
            return False
        self.passed_event = True

        return False
Exemple #20
0
    def eventhandler(self, event, menuw=None):
        update_bits = 0
        logger.debug('eventhandler(self, %s, %s) %s arg=%s', event, menuw, self, event.arg)

        if event == 'MIXER_MUTE':
            # it seems that the exent is received before the mixer has been set!
            self.set_mixer(self.mixer.getMuted() == 0)
            update_bits = 1
        elif event == 'MIXER_VOLDOWN' or event == 'MIXER_VOLUP':
            self.set_mixer(0)
            update_bits = 1
        elif event == 'PLAY' or event == 'PLAY_START':
            self.set_running(Play)
            self.playitem = event.arg
            update_bits = 1
        elif event == 'PLAY_END' or event == 'USER_END' or event == 'STOP':
            self.set_running(0)
            self.playitem = None
            update_bits = 1
        elif event == 'PAUSE':
            # two pauses resume play but leaves Pause!
            self.set_running(Pause)
            update_bits = 1
        elif event == 'SEEK':
            self.set_running((event.arg < 0 and Rewind) or FastForward)
            update_bits = 1
        elif event == 'VIDEO_START':
            self.set_running(Play)
            update_bits = 1
        elif event == 'VIDEO_END':
            self.set_running(Stop)
            update_bits = 1
        elif plugin.isevent(event) == 'IDENTIFY_MEDIA':
            media = event.arg[0]
            self.set_media((hasattr(media.item, 'type') and Clock) or 0)
            update_bits = 1
        elif plugin.isevent(event) == 'USB':
            pass
        elif event == 'FUNCTION_CALL':
            pass
        elif event == 'BUTTON':
            pass
        elif event == 'OSD_MESSAGE':
            pass
        elif event == 'TOGGLE_OSD':
            pass
        elif event == 'MENU_PROCESS_END':
            pass
        elif event == 'MENU_UP':
            pass
        elif event == 'MENU_DOWN':
            pass
        elif event == 'MENU_LEFT':
            pass
        elif event == 'MENU_DOWN':
            pass
        elif event == 'MENU_PAGEUP':
            pass
        elif event == 'MENU_PAGEDOWN':
            pass
        elif event == 'MENU_SELECT':
            pass
        elif event == 'MENU_PLAY_ITEM':
            pass
        elif event == 'MENU_SUBMENU':
            pass
        elif event == 'MENU_BACK_ONE_MENU':
            pass
        elif event == 'MENU_GOTO_MAINMENU':
            pass
        elif event == 'MENU_CALL_ITEM_ACTION':
            pass
        elif event == 'MENU_CHANGE_STYLE':
            pass
        elif event == 'INPUT_ENTER':
            pass
        elif event == 'TV_START_RECORDING':
            pass
        elif event == 'VIDEO_SEND_MPLAYER_CMD':
            pass
        elif event == 'VIDEO_MANUAL_SEEK':
            pass
        elif event == 'AUDIO_LOG':
            pass
        else:
            #_debug_('eventhandler(self, %s, %s) %s arg=%s' % (event, menuw, self, event.arg))
            logger.debug('\"%s\" not handled', event)

        if update_bits:
            self.icons()

        return 0