Package elisa :: Package plugins :: Package base :: Package actions :: Module enqueue_action
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.base.actions.enqueue_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   
18  __maintainer__ = 'Lionel Martin <lionel@fluendo.com>' 
19   
20   
21  from elisa.base_components.action import Action 
22  from elisa.core import player, common 
23  import time 
24   
25 -class EnqueueAction(Action):
26 """ 27 DOCME 28 """ 29 30 label = 'enqueue' 31 supported_file_types = ('audio', 'video') 32 33 # Attribute to set at initialization 34 # MediaURI instance 35 uri = None 36 # position to add the uri in playlist 37 # -1 : add at the end. 38 position = -1 39 # listmodel instance 40 player_model = None 41 42 # Options: 43 # if True, the playlist will be played after uri adding from the begining 44 play_now = True 45 # if True, the playlist will be removed before adding the new uri 46 erase_before_enqueue = True 47 48 # media_types supported by the media activity which creates this action 49 media_types = [] 50
51 - def __call__(self, controller, origin):
52 playlist_model = self.player_model.playlist 53 playlist_activity = playlist_model.activity 54 playlist_activity.media_types = self.media_types 55 56 if playlist_activity.loading: 57 self.warning("Already loading the playlist...") 58 return 59 60 if self.erase_before_enqueue: 61 playlist_activity.empty() 62 63 playlist_activity.add_uri(self.uri, -1) 64 65 if self.play_now==True: 66 67 def got_media_type(media_type, model): 68 self.player_model.media_type = media_type['file_type'] 69 uri = model[0] 70 self.player_model.uri = uri 71 self.player_model.state = player.STATES.PLAYING
72 73 def play_now(model): 74 dfr = None 75 if len(model): 76 uri = model[0] 77 media_manager = common.application.media_manager 78 dfr = media_manager.get_media_type(uri) 79 dfr.addCallback(got_media_type, model) 80 return dfr
81 82 # load items in the playlist 83 dfr = playlist_activity.loadmore(self.uri, playlist_model) 84 dfr.addCallback(play_now) 85