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

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

  1  # -*- coding: utf-8 -*- 
  2  # Elisa - Home multimedia server 
  3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
  4  # All rights reserved. 
  5  # 
  6  # This file is available under one of two license agreements. 
  7  # 
  8  # This file is licensed under the GPL version 3. 
  9  # See "LICENSE.GPL" in the root of this distribution including a special 
 10  # exception to use Elisa with Fluendo's plugins. 
 11  # 
 12  # The GPL part of Elisa is also available under a commercial licensing 
 13  # agreement from Fluendo. 
 14  # See "LICENSE.Elisa" in the root directory of this distribution package 
 15  # for details on that license. 
 16   
 17   
 18  __maintainer__ = 'Lionel Martin <lionel@fluendo.com>' 
 19   
 20   
 21  from elisa.base_components.view import View 
 22  from elisa.core import common 
 23  from elisa.core import player 
 24  from twisted.internet import reactor 
 25  from elisa.core.input_event import * 
 26   
 27  try: 
 28      from dvd_player import * 
 29      FLUENDO_DVD_INSTALLED = True 
 30  except: 
 31      FLUENDO_DVD_INSTALLED = False 
 32   
33 -class DvdPlayerView(View):
34 """ 35 This class implements a view which can create a 36 Player instance and manage it. 37 This class can be inherited to provide the 38 toolkit dependent display, as well as the 39 GStreamer video and audio sinks 40 """ 41 42 default_config={'gpl': 0} 43 config_doc = {'gpl': 'wether or not to use GPL GStreamer elements'} 44 45
46 - def initialize(self):
47 View.initialize(self) 48 if FLUENDO_DVD_INSTALLED: 49 gpl = int(self.config.get('gpl', '0')) 50 self.player = ElisaDVDPlayer(gpl) 51 self.player.in_menu.connect(self._in_menu) 52 else: 53 self.player = common.application.player_registry.create_player()
54
55 - def _in_menu(self, value):
57
58 - def attribute_set(self, origin, key, old_value, new_value):
59 View.attribute_set(self, origin, key, old_value, new_value) 60 if key == 'state': 61 if new_value == player.STATES.PLAYING: 62 self.state_changed(new_value) 63 self.player.play() 64 if self.player.is_menu and FLUENDO_DVD_INSTALLED: 65 self.player.fire_action(DVD_ACTION_MENU_ROOT_OR_RESUME) 66 elif new_value == player.STATES.PAUSED: 67 self.state_changed(new_value) 68 self.player.pause() 69 elif new_value == player.STATES.STOPPED: 70 self.state_changed(new_value) 71 self.player.stop() 72 elif key == 'uri': 73 self.player.load_uri(new_value) 74 self.uri_changed(new_value) 75 elif key == 'seek_to': 76 self.seek_to_changed(new_value) 77 elif key == 'volume': 78 self.player.volume = new_value 79 self.volume_changed(new_value) 80 elif key == 'muted': 81 self.player.muted = new_value 82 elif key == 'last_navigation_action' and FLUENDO_DVD_INSTALLED: 83 if new_value == EventAction.GO_UP: 84 self.player.fire_action(DVD_ACTION_BUTTON_UP) 85 86 elif new_value == EventAction.GO_DOWN: 87 self.player.fire_action(DVD_ACTION_BUTTON_DOWN) 88 89 elif new_value == EventAction.GO_LEFT: 90 if self.player.is_menu: 91 self.player.fire_action(DVD_ACTION_BUTTON_LEFT) 92 else: 93 self.player.fire_action(DVD_ACTION_SEARCH_PREV_PG) 94 95 elif new_value == EventAction.GO_RIGHT: 96 if self.player.is_menu: 97 self.player.fire_action(DVD_ACTION_BUTTON_RIGHT) 98 else: 99 self.player.fire_action(DVD_ACTION_SEARCH_NEXT_PG) 100 101 elif new_value == EventAction.DVD_MENU: 102 if not self.player.is_menu: 103 self.player.fire_action(DVD_ACTION_MENU_ROOT_OR_RESUME) 104 105 elif new_value == EventAction.OK: 106 self.player.fire_action(DVD_ACTION_BUTTON_ACTIVATE)
107
108 - def dvd_menu_visible_changed(self, is_visible):
110 111
112 - def state_changed(self, state):
117
118 - def _update_model_position(self):
119 if self.controller.model.duration != self.player.duration: 120 self.controller.model.duration = self.player.duration 121 self.controller.model.position = self.player.position 122 if self.controller.model.state == player.STATES.PLAYING: 123 reactor.callLater(0.5, self._update_model_position )
124
125 - def uri_changed(self, uri):
126 pass
127
128 - def seek_to_changed(self, position):
129 pass
130
131 - def volume_changed(self, volume):
132 pass
133
134 - def controller_changed(self, old_controller, new_controller):
135 if self.controller.uri != None: 136 self.player.load_uri(self.controller.uri) 137 138 state = self.controller.state 139 if state == player.STATES.PLAYING: 140 self.player.play() 141 elif state == player.STATES.PAUSED: 142 self.player.pause() 143 elif state == player.STATES.STOPPED: 144 self.player.stop()
145 146
147 - def _end_of_stream(self, uri):
148 self.controller.model.state = player.STATES.STOPPED
149