Package elisa :: Package plugins :: Package bad :: Package dvd :: Module dvd_player_controller
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.bad.dvd.dvd_player_controller

  1  # Elisa - Home multimedia server 
  2  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
  3  # All rights reserved. 
  4  # 
  5  # This file is available under one of two license agreements. 
  6  # 
  7  # This file is licensed under the GPL version 3. 
  8  # See "LICENSE.GPL" in the root of this distribution including a special 
  9  # exception to use Elisa with Fluendo's plugins. 
 10  # 
 11  # The GPL part of Elisa is also available under a commercial licensing 
 12  # agreement from Fluendo. 
 13  # See "LICENSE.Elisa" in the root directory of this distribution package 
 14  # for details on that license. 
 15   
 16   
 17  __maintainer__ = 'Lionel Martin <lionel@fluendo.com>' 
 18   
 19  from elisa.core.input_event import * 
 20  from elisa.core import common 
 21  from elisa.core import player 
 22  from elisa.core import plugin_registry 
 23  PlayerControllerClass = plugin_registry.get_component_class('base:player_controller') 
 24  from elisa.core.bus.bus_message import DeviceAction 
 25   
 26   
 27   
28 -class DvdPlayerController(PlayerControllerClass):
29 30 supported_models = ('dvd:dvd_player_model',) 31 bindings = {'last_navigation_action': 'last_navigation_action', 32 'in_menu': 'in_menu', 33 # FIXME: inherited from base:player_controller 34 'playlist': 'playlist', 35 'seek_to': 'seek_to', 36 'volume': 'volume', 37 'muted': 'muted', 38 'pause_requested': 'pause_requested', 39 'uri': 'uri'} 40 41 42 last_navigation_action = None 43 #default_config = {} 44 in_menu = False 45
46 - def __init__(self):
49
50 - def _got_bus_message(self, message, sender):
51 if message.action == message.ActionType.LOCATION_ADDED and \ 52 message.fstype == 'dvd': 53 #self.model.state = player.STATES.PLAYING 54 #FIXME : Can't do it because I revieve a signal when the dvd is in the reader at elisa starting 55 self.info("start to play dvd automaticly") 56 if message.action == message.ActionType.EJECT and \ 57 message.fstype == 'dvd': 58 self.model.state = player.STATES.STOPPED
59 60
61 - def attribute_set(self, origin, key, old_value, new_value):
62 PlayerControllerClass.attribute_set(self, origin, key, old_value, new_value) 63 if key == 'menu_requested': 64 if new_value: 65 self.model.last_navigation_action = EventAction.DVD_MENU
66
67 - def focus_changed(self, value):
68 if value == True and self.model.state != player.STATES.PLAYING: 69 self.model.state = player.STATES.PLAYING
70
71 - def handle_input(self, input_event):
72 if input_event.action == EventAction.PLAY: 73 self.stopped = False 74 self.model.state = player.STATES.PLAYING 75 76 elif input_event.action == EventAction.PAUSE: 77 self.stopped = False 78 self.model.state = player.STATES.PAUSED 79 80 elif input_event.action == EventAction.STOP: 81 self.stopped = True 82 self.model.state = player.STATES.STOPPED 83 elif input_event.action == EventAction.VOL_UP: 84 if self.model.volume < 10: 85 self.model.volume += self._volume_increment_step 86 87 elif input_event.action == EventAction.VOL_DOWN: 88 if self.model.volume > 0: 89 self.model.volume -= self._volume_decrement_step 90 91 if input_event.action in (EventAction.GO_LEFT, EventAction.GO_RIGHT): 92 self.model.last_navigation_action = input_event.action 93 elif not self.in_menu: 94 PlayerControllerClass.handle_input(self, input_event) 95 elif input_event.action in (EventAction.GO_UP, EventAction.GO_DOWN, 96 EventAction.OK, EventAction.DVD_MENU): 97 #FIXME : temporary code 98 self.model.last_navigation_action = input_event.action 99 100 return False
101
102 - def state_changed(self, state):
103 if self.model.state == player.STATES.PLAYING and not self.focused: 104 self.focus() 105 elif self.focused and state == player.STATES.STOPPED: 106 self.parent.focus()
107