Package elisa :: Package plugins :: Package good :: Package xmlmenu :: Package actions :: Module play_action
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.good.xmlmenu.actions.play_action

 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  __maintainer__ = 'Benjamin Kampmann <benjamin@fluendo.com>' 
18   
19  from elisa.base_components.action import Action 
20  from elisa.core import player 
21  from elisa.core import plugin_registry 
22   
23   
24 -class PlayAction(Action):
25 """ 26 Play mediafile 27 """
28 - def __init__(self):
29 Action.__init__(self) 30 self.player_model = None 31 self.media_type = 'audio' 32 #WEAK-Reference! 33 self.model = None
34
35 - def __call__(self, controller, origin):
36 model = self.model() 37 if not model: 38 return 39 40 if hasattr(model, 'uri') and model.uri != None: 41 if self.player_model.state == player.STATES.PLAYING and \ 42 self.player_model.media_type == 'audio': 43 if model in self.player_model.playlist: 44 # Already in the list, we should play it 45 self.player_model.uri = model.uri 46 self.player_model.state = player.STATES.PLAYING 47 else: 48 self.player_model.playlist.append(model) 49 else: 50 self.player_model.playlist.append(model) 51 self.player_model.uri = model.uri 52 self.player_model.media_type = self.media_type 53 self.player_model.state = player.STATES.PLAYING
54