def do_operation(self, operation): # print 'do_operation ',operation self.mon.trace(self, operation) if operation == 'exit': self.exit() elif operation == 'stop': if self.level != 0: # not at top so stop the show self.user_stop_signal = True # and stop the track first if self.current_player is not None: self.current_player.input_pressed('stop') else: # at top, just stop track if running if self.current_player is not None: self.current_player.input_pressed('stop') elif operation == 'up' and self.state == 'playing': # print '\nUP' self.previous() elif operation == 'down' and self.state == 'playing': next(self) elif operation == 'repeat' and self.state == 'playing': self.repeat() elif operation == 'play': # use 'play' to start child if state=playing or to trigger the show if waiting for trigger if self.state == 'playing': if self.show_params['child-track-ref'] != '': # set a signal because must stop current track before running child show self.play_child_signal = True self.child_track_ref = self.show_params['child-track-ref'] # and stop the current track if its running if self.current_player is not None: self.current_player.input_pressed('stop') else: if self.state == 'waiting': self.mon.stats(self.show_params['type'], self.show_params['show-ref'], self.show_params['title'], 'start trigger', '', '', '') Show.delete_admin_message(self) self.start_list() elif operation in ('pause', 'pause-on', 'pause-off', 'mute', 'unmute', 'go', 'inc-volume', 'dec-volume'): if self.current_player is not None: self.current_player.input_pressed(operation) elif operation in ('no-command', 'null'): return # if the operation is omxplayer mplayer or uzbl runtime control then pass it to player if running elif operation[0:4] == 'omx-' or operation[ 0:6] == 'mplay-' or operation[0:5] == 'uzbl-': if self.current_player is not None: self.current_player.input_pressed(operation)
def track_ready_callback(self,enable_show_background): self.delete_eggtimer() # get control bindings for this show # needs to be done for each track as track can override the show controls if self.show_params['disable-controls'] == 'yes': self.controls_list=[] else: reason,message,self.controls_list= self.controlsmanager.get_controls(self.show_params['controls']) if reason=='error': self.mon.err(self,message) self.end('error',"error in controls: " + message) return # print 'controls',reason,self.show_params['controls'],self.controls_list #merge controls from the track controls_text=self.current_player.get_links() reason,message,track_controls=self.controlsmanager.parse_controls(controls_text) if reason == 'error': self.mon.err(self,message + " in track: "+ self.current_player.track_params['track-ref']) self.error_signal=True self.what_next_after_showing() self.controlsmanager.merge_controls(self.controls_list,track_controls) # enable the click-area that are in the list of controls self.sr.enable_click_areas(self.controls_list) Show.base_track_ready_callback(self,enable_show_background)
def play(self,end_callback,show_ready_callback, parent_kickback_signal,level,controls_list): self.mon.newline(3) self.mon.trace(self, self.show_params['show-ref']) Show.base_play(self,end_callback,show_ready_callback,parent_kickback_signal, level,controls_list) # unpack show parameters reason,message,self.show_timeout = Show.calculate_duration(self,self.show_params['show-timeout']) if reason=='error': self.mon.err(self,'ShowTimeout has bad time: '+self.show_params['show-timeout']) self.end('error','ShowTimeout has bad time: '+self.show_params['show-timeout']) self.track_count_limit = int(self.show_params['track-count-limit']) reason,message,self.interval = Show.calculate_duration (self, self.show_params['interval']) if reason=='error': self.mon.err(self,'Interval has bad time: '+self.show_params['interval']) self.end('error','Interval has bad time: '+self.show_params['interval']) if self.medialist.anon_length()==0 and self.show_params['type'] not in ('liveshow','artliveshow'): self.mon.err(self,'No anonymous tracks in medialist ') self.end('error','No anonymous tracks in medialist ') # delete eggtimer started by the parent if self.previous_shower is not None: self.previous_shower.delete_eggtimer() self.start_show()
def end(self,reason,message): Show.delete_admin_message(self) self.base_withdraw_show_background() self.base_delete_show_background() self.mon.log(self,"Ending Artshow: "+ self.show_params['show-ref']) self.end_callback(self.show_id,reason,message) self=None
def start_load_show_loop(self,selected_track): # shuffle players Show.base_shuffle(self) # print '\nSHUFFLED previous is', self.mon.id(self.previous_player) self.mon.trace(self,'') self.display_eggtimer() if self.track_timeout_timer is not None: self.canvas.after_cancel(self.track_timeout_timer) self.track_timeout_timer=None # start timeout for the track if required if self.current_track_ref != self.first_track_ref and self.track_timeout != 0: self.track_timeout_timer=self.canvas.after(self.track_timeout*1000,self.track_timeout_callback) # read the show links. Track links will be added by ready_callback # needs to be done in show loop as each track adds different links to the show links if self.show_params['disable-controls'] == 'yes': self.links=[] else: reason,message,self.links=self.path.parse_links(self.show_params['links'],self.allowed_links) if reason == 'error': self.mon.err(self,message + " in show") self.end('error',message + " in show") # load the track or show # params - track,, track loaded callback, end eshoer callback,enable_menu Show.base_load_track_or_show(self,selected_track,self.what_next_after_load,self.end_shower,False)
def load_first_track(self): self.mon.trace(self,'') if self.medialist.start() is False: # list is empty - display a message for 5 secs and then retry Show.display_admin_message(self,self.show_params['empty-text']) self.canvas.after(5000,self.remove_list_empty_message) else: # otherwise load the first track # print "!!!!! artshow init first" self.next_player=Show.base_init_selected_player(self,self.medialist.selected_track()) if self.next_player is None: self.mon.err(self,"Track Type cannot be played by this show: "+self.medialist.selected_track()['type']) self.req_next='error' self.what_next() else: # messageplayer passes the text not a file name if self.medialist.selected_track()['type'] == 'message': track_file=self.medialist.selected_track()['text'] else: track_file=Show.base_complete_path(self,self.medialist.selected_track()['location']) # print "!!!!! artshow load first ",track_file self.next_player.load(track_file, self.loaded_callback, enable_menu=False) self.wait_for_load()
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): # init the common bits Show.base__init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback) # delay in mS before next track is loaded after showing a track. # can be reduced if animation is not required self.load_delay = 2000 # Init variables for this show self.end_medialist_signal=False self.end_medialist_warning=False self.next_track_signal=False self.state='closed' self.req_next=''
def handle_input_event_this_show(self,symbol): self.mon.trace(self, "Handling input event in this show: " + symbol + " State:" + self.state) # check symbol against mediashow triggers if self.state == 'waiting' and self.show_params['trigger-start-type'] in ('input','input-persist') and symbol == self.show_params['trigger-start-param']: self.mon.stats(self.show_params['type'],self.show_params['show-ref'],self.show_params['title'],'start trigger', '','','') Show.delete_admin_message(self) self.start_list() elif self.state == 'playing' and self.show_params['trigger-end-type'] == 'input' and symbol == self.show_params['trigger-end-param']: self.end_trigger_signal=True if self.shower is not None: self.shower.do_operation('stop') elif self.current_player is not None: self.current_player.input_pressed('stop') elif self.state == 'playing' and self.show_params['trigger-next-type'] == 'input' and symbol == self.show_params['trigger-next-param']: self.mon.stats(self.show_params['type'],self.show_params['show-ref'],self.show_params['title'],'next trigger', '','','') self.mon.trace(self, "trigger-next-type detected; Calling next()") self.next() else: # event is not a trigger so must be internal operation operation=self.base_lookup_control(symbol,self.controls_list) if operation != '': self.do_operation(operation) else: self.mon.trace(self, "No operation found for event")
def end(self, reason, message): Show.delete_admin_message(self) self.base_withdraw_show_background() self.base_delete_show_background() self.mon.log(self, "Ending Artshow: " + self.show_params['show-ref']) self.end_callback(self.show_id, reason, message) self = None
def start_load_show_loop(self, selected_track): # uncomment the next line to write stats for every track # Show.write_stats(self,'play a track',self.show_params,selected_track) # shuffle players Show.base_shuffle(self) self.delete_eggtimer() # is child track required if self.show_params['child-track-ref'] != '': self.enable_child = True else: self.enable_child = False # read the show links. Track links will be added by ready_callback # needs to be done in show loop as each track adds different links to the show links if self.show_params['disable-controls'] == 'yes': self.links = [] else: reason, message, self.links = self.path.parse_links( self.show_params['links'], self.allowed_links) if reason == 'error': self.mon.err(self, message + " in show") self.end('error', message + " in show") # load the track or show # params - track,enable_menu enable = self.enable_child & self.enable_hint Show.base_load_track_or_show(self, selected_track, self.what_next_after_load, self.end_shower, enable)
def load_first_track(self): self.mon.trace(self, '') self.medialist.create_new_livelist() self.medialist.use_new_livelist() if self.medialist.start() is False: # print 'FIRST EMPTY' # list is empty - display a message for 5 secs and then retry Show.display_admin_message(self, self.show_params['empty-text']) self.canvas.after(5000, self.remove_list_empty_message) else: # otherwise load the first track # print "!!!!! artshow init first" # print 'after wait EMPTY' self.next_player = Show.base_init_selected_player( self, self.medialist.selected_track()) if self.next_player is None: self.mon.err( self, "Track Type cannot be played by this show: " + self.medialist.selected_track()['type']) self.req_next = 'error' self.what_next() else: # messageplayer passes the text not a file name if self.medialist.selected_track()['type'] == 'message': track_file = self.medialist.selected_track()['text'] else: track_file = Show.base_complete_path( self, self.medialist.selected_track()['location']) # print "!!!!! artshow load first ",track_file self.next_player.load(track_file, self.loaded_callback, enable_menu=False) self.wait_for_load()
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): # init the common bits Show.base__init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback) # instatiatate the screen driver - used only to access enable and hide click areas self.sr = ScreenDriver() self.controlsmanager = ControlsManager() # Init variables special to this show self.poll_for_interval_timer = None self.interval_timer_signal = False self.waiting_for_interval = False self.interval_timer = None self.duration_timer = None self.end_trigger_signal = False self.next_track_signal = False self.previous_track_signal = False self.play_child_signal = False self.error_signal = False self.show_timeout_signal = False self.req_next = 'nil' self.state = 'closed' self.count = 0 self.interval = 0 self.duration = 0 self.controls_list = [] self.enable_hint = True
def handle_input_event_this_show(self, symbol): # check symbol against mediashow triggers if self.state == 'waiting' and self.show_params[ 'trigger-start-type'] in ( 'input', 'input-persist' ) and symbol == self.show_params['trigger-start-param']: self.mon.stats(self.show_params['type'], self.show_params['show-ref'], self.show_params['title'], 'start trigger', '', '', '') Show.delete_admin_message(self) self.start_list() elif self.state == 'playing' and self.show_params[ 'trigger-end-type'] == 'input' and symbol == self.show_params[ 'trigger-end-param']: self.end_trigger_signal = True if self.shower is not None: self.shower.do_operation('stop') elif self.current_player is not None: self.current_player.input_pressed('stop') elif self.state == 'playing' and self.show_params[ 'trigger-next-type'] == 'input' and symbol == self.show_params[ 'trigger-next-param']: self.mon.stats(self.show_params['type'], self.show_params['show-ref'], self.show_params['title'], 'next trigger', '', '', '') self.next() else: # event is not a trigger so must be internal operation operation = self.base_lookup_control(symbol, self.controls_list) if operation != '': self.do_operation(operation)
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): """ show_id - index of the top level show caling this (for debug only) show_params - dictionary section for the menu canvas - the canvas that the menu is to be written on showlist - the showlist pp_dir - Pi Presents directory pp_home - Pi presents data_home directory pp_profile - Pi presents profile directory """ # init the common bits Show.base__init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback) # instatiatate the screen driver - used only to access enable and hide click areas self.sr = ScreenDriver() # create an instance of PathManager - only used to parse the links. self.path = PathManager() self.allowed_links = ('play', 'pause', 'exit', 'return', 'null', 'no-command', 'stop', 'pause-on', 'pause-off', 'mute', 'unmute', 'go') # init variables self.links = [] self.track_timeout_timer = None self.show_timeout_timer = None self.next_track_signal = False self.current_track_ref = '' self.req_next = ''
def play(self, end_callback, show_ready_callback, parent_kickback_signal, level, controls_list): self.mon.newline(3) self.mon.trace(self, self.show_params['show-ref']) Show.base_play(self, end_callback, show_ready_callback, parent_kickback_signal, level, controls_list) # unpack show parameters reason, message, self.show_timeout = Show.calculate_duration( self, self.show_params['show-timeout']) if reason == 'error': self.mon.err( self, 'ShowTimeout has bad time: ' + self.show_params['show-timeout']) self.end( 'error', 'ShowTimeout has bad time: ' + self.show_params['show-timeout']) self.track_count_limit = int(self.show_params['track-count-limit']) reason, message, self.interval = Show.calculate_duration( self, self.show_params['interval']) if reason == 'error': self.mon.err( self, 'Interval has bad time: ' + self.show_params['interval']) self.end('error', 'Interval has bad time: ' + self.show_params['interval']) # delete eggtimer started by the parent if self.previous_shower is not None: self.previous_shower.delete_eggtimer() self.start_show()
def start_load_show_loop(self, selected_track): # shuffle players Show.base_shuffle(self) # print '\nSHUFFLED previous is', self.mon.id(self.previous_player) self.mon.trace(self, '') self.display_eggtimer() if self.track_timeout_timer is not None: self.canvas.after_cancel(self.track_timeout_timer) self.track_timeout_timer = None # start timeout for the track if required if self.current_track_ref != self.first_track_ref and self.track_timeout != 0: self.track_timeout_timer = self.canvas.after( self.track_timeout * 1000, self.track_timeout_callback) # read the show links. Track links will be added by ready_callback # needs to be done in show loop as each track adds different links to the show links if self.show_params['disable-controls'] == 'yes': self.links = [] else: reason, message, self.links = self.path.parse_links( self.show_params['links'], self.allowed_links) if reason == 'error': self.mon.err(self, message + " in show") self.end('error', message + " in show") # load the track or show # params - track,, track loaded callback, end eshoer callback,enable_menu Show.base_load_track_or_show(self, selected_track, self.what_next_after_load, self.end_shower, False)
def play(self,end_callback,show_ready_callback,parent_kickback_signal,level,controls_list): """ starts the hyperlink show at start-track end_callback - function to be called when the show exits show_ready_callback - callback to get the previous track level is 0 when the show is top level (run from [start] or from show control) parent_kickback_signal - not used other than it being passed to a show """ # need to instantiate the medialist here as in gapshow done in derived class self.medialist=MediaList('ordered') Show.base_play(self,end_callback,show_ready_callback, parent_kickback_signal,level,controls_list) self.mon.trace(self,self.show_params['show-ref']) #parse the show and track timeouts reason,message,self.show_timeout=Show.calculate_duration(self,self.show_params['show-timeout']) if reason =='error': self.mon.err(self,'Show Timeout has bad time: '+self.show_params['show-timeout']) self.end('error','show timeout, bad time: '+self.show_params['show-timeout']) reason,message,self.track_timeout=Show.calculate_duration(self,self.show_params['track-timeout']) if reason=='error': self.mon.err(self,'Track Timeout has bad time: '+self.show_params['track-timeout']) self.end('error','track timeout, bad time: '+self.show_params['track-timeout']) # and delete eggtimer if self.previous_shower is not None: self.previous_shower.delete_eggtimer() self.do_first_track()
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): """ show_id - index of the top level show caling this (for debug only) show_params - dictionary section for the menu canvas - the canvas that the menu is to be written on showlist - the showlist pp_dir - Pi Presents directory pp_home - Pi presents data_home directory pp_profile - Pi presents profile directory """ # init the common bits Show.base__init__( self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback ) # instatiatate the screen driver - used only to access enable and hide click areas self.sr = ScreenDriver() self.controlsmanager = ControlsManager() # init variables self.show_timeout_timer = None self.track_timeout_timer = None self.next_track_signal = False self.next_track = None self.menu_index = 0 self.menu_showing = True self.req_next = ""
def end_shower(self,show_id,reason,message): self.mon.log(self,self.show_params['show-ref']+ ' '+ str(self.show_id)+ ': Returned from shower with ' + reason +' ' + message) self.sr.hide_click_areas(self.links) self.req_next=reason Show.base_end_shower(self) # print 'end shower - wha-next' self.what_next_after_showing()
def wait_for_not_empty(self): if self.medialist.display_length()==0: # list is empty retry after 5 secs self.canvas.after(5000,self.wait_for_not_empty) else: Show.delete_admin_message(self) self.not_empty()
def wait_for_not_empty(self): if self.medialist.display_length() == 0: # list is empty retry after 5 secs self.canvas.after(5000, self.wait_for_not_empty) else: Show.delete_admin_message(self) self.not_empty()
def track_ready_callback(self, enable_show_background): self.delete_eggtimer() # get control bindings for this show # needs to be done for each track as track can override the show controls if self.show_params['disable-controls'] == 'yes': self.controls_list = [] else: reason, message, self.controls_list = self.controlsmanager.get_controls( self.show_params['controls']) if reason == 'error': self.mon.err(self, message) self.end('error', "error in controls: " + message) return # print 'controls',reason,self.show_params['controls'],self.controls_list #merge controls from the track controls_text = self.current_player.get_links() reason, message, track_controls = self.controlsmanager.parse_controls( controls_text) if reason == 'error': self.mon.err( self, message + " in track: " + self.current_player.track_params['track-ref']) self.error_signal = True self.what_next_after_showing() self.controlsmanager.merge_controls(self.controls_list, track_controls) # enable the click-area that are in the list of controls self.sr.enable_click_areas(self.controls_list) Show.base_track_ready_callback(self, enable_show_background)
def play(self,end_callback,show_ready_callback, parent_kickback_signal,level,controls_list): self.mon.newline(3) self.mon.trace(self, self.show_params['show-ref']) Show.base_play(self,end_callback,show_ready_callback,parent_kickback_signal, level,controls_list) # unpack show parameters reason,message,self.show_timeout = Show.calculate_duration(self,self.show_params['show-timeout']) if reason=='error': self.mon.err(self,'ShowTimeout has bad time: '+self.show_params['show-timeout']) self.end('error','ShowTimeout has bad time: '+self.show_params['show-timeout']) self.track_count_limit = int(self.show_params['track-count-limit']) reason,message,self.interval = Show.calculate_duration (self, self.show_params['interval']) if reason=='error': self.mon.err(self,'Interval has bad time: '+self.show_params['interval']) self.end('error','Interval has bad time: '+self.show_params['interval']) if self.medialist.anon_length()==0 and self.show_params['type'] not in ('liveshow','artliveshow'): self.mon.err(self,'No anonymous tracks in medialist ') self.end('error','No anonymous tracks in medialist ') if self.show_params['trigger-next-type']=='input': self.wait_for_next_trigger=True else: self.wait_for_next_trigger=False # delete eggtimer started by the parent if self.previous_shower is not None: self.previous_shower.delete_eggtimer() self.playing_track=False self.start_show()
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): """ show_id - index of the top level show caling this (for debug only) show_params - dictionary section for the menu canvas - the canvas that the menu is to be written on showlist - the showlist pp_dir - Pi Presents directory pp_home - Pi presents data_home directory pp_profile - Pi presents profile directory """ # init the common bits Show.base__init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback) # instatiatate the screen driver - used only to access enable and hide click areas self.sr = ScreenDriver() self.controlsmanager = ControlsManager() # init variables self.show_timeout_timer = None self.track_timeout_timer = None self.next_track_signal = False self.next_track = None self.menu_index = 0 self.menu_showing = True self.req_next = '' self.last_menu_index = 0 self.return_to_zero = False
def play(self, end_callback, show_ready_callback, parent_kickback_signal, level, controls_list): """ displays the menu end_callback - function to be called when the menu exits show_ready_callback - callback when menu is ready to display (not used) level is 0 when the show is top level (run from [start] or from show control) parent_kickback_signal - not used other than it being passed to a show """ # need to instantiate the medialist here as not using gapshow self.medialist = MediaList("ordered") Show.base_play(self, end_callback, show_ready_callback, parent_kickback_signal, level, controls_list) self.mon.trace(self, self.show_params["show-ref"]) # parse the show and track timeouts reason, message, self.show_timeout = Show.calculate_duration(self, self.show_params["show-timeout"]) if reason == "error": self.mon.err(self, "Show Timeout has bad time: " + self.show_params["show-timeout"]) self.end("error", "show timeout, bad time") reason, message, self.track_timeout = Show.calculate_duration(self, self.show_params["track-timeout"]) if reason == "error": self.mon.err(self, "Track Timeout has bad time: " + self.show_params["track-timeout"]) self.end("error", "track timeout, bad time") # and delete eggtimer if self.previous_shower is not None: self.previous_shower.delete_eggtimer() # and display the menu self.do_menu_track()
def end_shower(self, show_id, reason, message): self.mon.log( self, self.show_params['show-ref'] + ' ' + str(self.show_id) + ': Returned from shower with ' + reason + ' ' + message) self.sr.hide_click_areas(self.controls_list) self.req_next = reason Show.base_end_shower(self) self.what_next_after_showing()
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): """ show_id - index of the top level show caling this (for debug only) show_params - dictionary section for the menu canvas - the canvas that the menu is to be written on showlist - the showlist pp_dir - Pi Presents directory pp_home - Pi presents data_home directory pp_profile - Pi presents profile directory """ # init the common bits Show.base__init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback) # instatiatate the screen driver - used only to access enable and hide click areas self.sr=ScreenDriver() # create a path stack and control path debugging if self.show_params['debug-path']=='yes': self.debug=True else: self.debug=False self.path = PathManager() self.allowed_links=('return','home','call','null','exit','goto','play','jump','repeat','pause','no-command','stop','pause-on','pause-off','mute','unmute','go') # init variables self.track_timeout_timer=None self.show_timeout_timer=None self.next_track_signal=False self.next_track_ref='' self.current_track_ref='' self.current_track_type='' self.req_next=''
def what_next_after_showing(self): self.mon.trace(self, '') # print 'WHAT NEXT AFTER SHOWING' # print 'current is',self.mon.id(self.current_player), ' next track signal ',self.next_track_signal # need to terminate if self.terminate_signal is True: self.terminate_signal=False # what to do when closed or unloaded self.ending_reason='killed' Show.base_close_or_unload(self) elif self.req_next== 'error': self.req_next='' # set what to do after closed or unloaded self.ending_reason='error' Show.base_close_or_unload(self) # show timeout elif self.show_timeout_signal is True: self.show_timeout_signal=False # what to do when closed or unloaded self.ending_reason='show-timeout' Show.base_close_or_unload(self) # used by exit for stopping show from other shows. elif self.exit_signal is True: self.exit_signal=False self.ending_reason='exit' Show.base_close_or_unload(self) # user wants to stop elif self.user_stop_signal is True: self.user_stop_signal=False self.ending_reason='user-stop' Show.base_close_or_unload(self) # user has selected another track elif self.next_track_signal is True: self.next_track_signal=False self.current_track_ref=self.next_track_arg # print 'what next - next track signal is True so load ', self.current_track_ref index = self.medialist.index_of_track(self.current_track_ref) if index >=0: # don't use select the track as not using selected_track in radiobuttonshow # and load it self.start_load_show_loop(self.medialist.track(index)) else: self.mon.err(self,"next track not found in medialist: "+ self.current_track_ref) self.end('error',"next track not found in medialist") else: # track ends naturally or is quit so go back to first track # print 'what next - natural end so do first track' self.do_first_track()
def do_operation(self,operation): # print 'do_operation ',operation self.mon.trace(self, operation) if operation == 'exit': self.exit() elif operation == 'stop': if self.level != 0 : # not at top so stop the show self.user_stop_signal=True # and stop the track first if self.current_player is not None: self.current_player.input_pressed('stop') else: # at top, just stop track if running if self.current_player is not None: self.current_player.input_pressed('stop') elif operation == 'up' and self.state == 'playing': # print '\nUP' self.previous() elif operation == 'down' and self.state == 'playing': self.next() elif operation == 'play': # use 'play' to start child if state=playing or to trigger the show if waiting for trigger if self.state == 'playing': if self.show_params['child-track-ref'] != '': # set a signal because must stop current track before running child show self.play_child_signal=True self.child_track_ref=self.show_params['child-track-ref'] # and stop the current track if its running if self.current_player is not None: self.current_player.input_pressed('stop') else: if self.state == 'waiting': self.mon.stats(self.show_params['type'],self.show_params['show-ref'],self.show_params['title'],'start trigger', '','','') Show.delete_admin_message(self) self.start_list() elif operation in ('pause','pause-on','pause-off','mute','unmute','go'): if self.current_player is not None: self.current_player.input_pressed(operation) elif operation in ('no-command','null'): return # if the operation is omxplayer mplayer or uzbl runtime control then pass it to player if running elif operation[0:4] == 'omx-' or operation[0:6] == 'mplay-'or operation[0:5] == 'uzbl-': if self.current_player is not None: self.current_player.input_pressed(operation)
def end_shower(self,show_id,reason,message): self.mon.log(self,self.show_params['show-ref']+ ' '+ str(self.show_id)+ ': Returned from shower with ' + reason +' ' + message) self.sr.hide_click_areas(self.links) if reason == 'error': self.req_next='error' self.what_next_after_showing() else: Show.base_end_shower(self) self.next_track_signal=True self.next_track_op='return-by' self.next_track_arg='1' self.what_next_after_showing()
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): # init the common bits Show.base__init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback) # instatiatate the screen driver - used only to access enable and hide click areas self.sr=ScreenDriver() self.controlsmanager=ControlsManager() # Init variables special to this show self.poll_for_interval_timer=None self.interval_timer_signal=False self.waiting_for_interval=False self.interval_timer=None self.duration_timer=None self.end_trigger_signal=False self.next_track_signal=False self.previous_track_signal=False self.play_child_signal = False self.error_signal=False self.show_timeout_signal=False self.req_next='nil' self.state='closed' self.count=0 self.interval=0 self.duration=0 self.controls_list=[] self.enable_hint= True self.escapetrack_required=False
def play(self,end_callback,show_ready_callback, parent_kickback_signal,level,controls_list): self.mon.trace(self,self.show_params['show-ref']) Show.base_play(self,end_callback,show_ready_callback,parent_kickback_signal, level,controls_list) # get the previous shower and player from calling show # Show.base_get_previous_player_from_parent(self) # and delete eggtimer started by the parent if self.previous_shower is not None: self.previous_shower.delete_eggtimer() self.wait_for_trigger()
def start_list(self): # starts the list or any repeat having waited for trigger first. self.state='playing' # initialise track counter for the list self.track_count=0 # start interval timer self.interval_timer_signal = False if self.interval != 0: self.interval_timer=self.canvas.after(self.interval*1000,self.end_interval_timer) #get rid of previous track in order to display the empty message if self.medialist.display_length() == 0: if self.show_params['empty-text']: Show.base_shuffle(self) Show.base_track_ready_callback(self,False) Show.display_admin_message(self,self.show_params['empty-text']) self.wait_for_not_empty() else: self.stop_timers() self.ending_reason='exit' Show.base_close_or_unload(self) else: self.not_empty()
def play(self, end_callback, show_ready_callback, parent_kickback_signal, level, controls_list): """ starts the hyperlink show at start-track end_callback - function to be called when the show exits show_ready_callback - callback to get previous show and track level is 0 when the show is top level (run from [start] or from show control) parent_kickback_signal is not used passed to subshow by base class as parent_kickback_signal """ # need to instantiate the medialist here as in gapshow done in derived class self.medialist = MediaList('ordered') Show.base_play(self, end_callback, show_ready_callback, parent_kickback_signal, level, controls_list) #dummy as it gets passed down to subshow, however it isn't actuallly used. self.controls_list = [] self.mon.trace(self, self.show_params['show-ref']) # read show destinations self.first_track_ref = self.show_params['first-track-ref'] self.home_track_ref = self.show_params['home-track-ref'] self.timeout_track_ref = self.show_params['timeout-track-ref'] #parse the show and track timeouts reason, message, self.show_timeout = Show.calculate_duration( self, self.show_params['show-timeout']) if reason == 'error': self.mon.err( self, 'Show Timeout has bad time: ' + self.show_params['show-timeout']) self.end( 'error', 'show timeout, bad time: ' + self.show_params['show-timeout']) reason, message, self.track_timeout = Show.calculate_duration( self, self.show_params['track-timeout']) if reason == 'error': self.mon.err( self, 'Track Timeout has bad time: ' + self.show_params['track-timeout']) self.end( 'error', 'track timeout, bad time: ' + self.show_params['track-timeout']) # and delete eggtimer if self.previous_shower is not None: self.previous_shower.delete_eggtimer() self.do_first_track()
def start_list(self): # starts the list or any repeat having waited for trigger first. self.state = 'playing' # initialise track counter for the list self.track_count = 0 # start interval timer self.interval_timer_signal = False if self.interval != 0: self.interval_timer = self.canvas.after(self.interval * 1000, self.end_interval_timer) #get rid of previous track in order to display the empty message if self.medialist.display_length() == 0: if self.show_params['empty-text']: Show.base_shuffle(self) Show.base_track_ready_callback(self, False) Show.display_admin_message(self, self.show_params['empty-text']) self.wait_for_not_empty() else: self.stop_timers() self.ending_reason = 'exit' Show.base_close_or_unload(self) else: self.not_empty()
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): """ show_id - index of the top level show caling this (for debug only) show_params - dictionary section for the menu canvas - the canvas that the menu is to be written on showlist - the showlist pp_dir - Pi Presents directory pp_home - Pi presents data_home directory pp_profile - Pi presents profile directory """ # init the common bits Show.base__init__( self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback ) # instatiatate the screen driver - used only to access enable and hide click areas self.sr = ScreenDriver() # create a path stack and control path debugging if self.show_params["debug-path"] == "yes": self.debug = True else: self.debug = False self.path = PathManager() self.allowed_links = ( "return", "home", "call", "null", "exit", "goto", "play", "jump", "repeat", "pause", "no-command", "stop", ) # init variables self.track_timeout_timer = None self.show_timeout_timer = None self.next_track_signal = False self.next_track_ref = "" self.current_track_ref = "" self.current_track_type = "" self.req_next = ""
def what_next_after_showing(self): self.mon.trace(self, "") # cancel track timeout timer if self.track_timeout_timer is not None: self.canvas.after_cancel(self.track_timeout_timer) self.track_timeout_timer = None # need to terminate? if self.terminate_signal is True: self.terminate_signal = False # set what to do when closed or unloaded self.ending_reason = "killed" Show.base_close_or_unload(self) elif self.req_next == "error": self.req_next = "" # set what to do after closed or unloaded self.ending_reason = "error" Show.base_close_or_unload(self) # show timeout elif self.show_timeout_signal is True: self.show_timeout_signal = False # set what to do when closed or unloaded self.ending_reason = "show-timeout" Show.base_close_or_unload(self) # used by exit for stopping show from other shows. elif self.exit_signal is True: self.exit_signal = False self.ending_reason = "exit" Show.base_close_or_unload(self) # user wants to stop elif self.user_stop_signal is True: self.user_stop_signal = False self.ending_reason = "user-stop" Show.base_close_or_unload(self) elif self.next_track_signal is True: self.next_track_signal = False self.menu_showing = False # start timeout for the track if required if self.track_timeout != 0: self.track_timeout_timer = self.canvas.after(self.track_timeout * 1000, self.track_timeout_callback) self.start_load_show_loop(self.next_track) else: # no stopping the show required so re-display the menu self.do_menu_track()
def what_to_load_next(self): self.mon.trace(self, self.pretty_state()) # closing down so don't load anything if self.ending_reason in ('killed', 'error'): return # wanting to exit so don't load just skip to what-next if self.terminate_signal is True or self.exit_signal is True or self.req_next == 'error': self.what_next() # has content of list been changed (replaced if it has, used for content of livelist) # print 'WHAT to load NEXT' self.medialist.create_new_livelist() # print result, self.medialist.new_length(),self.medialist.anon_length() if self.medialist.livelist_changed() is True: # print 'ITS CHANGED' self.ending_reason = 'change-medialist' self.close_current_and_next() else: # get the next track and init player self.medialist.next(self.show_params['sequence']) Show.delete_admin_message(self) if self.medialist.at_end() is True: self.end_medialist_warning = True # print "!!!!! artshow init next " self.next_player = Show.base_init_selected_player( self, self.medialist.selected_track()) if self.next_player is None: self.mon.err( self, "Track Type cannot be played by this show: " + self.medialist.selected_track()['type']) self.req_next = 'error' self.what_next() else: # load the next track while current is showing # messageplayer passes the text not a file name if self.medialist.selected_track()['type'] == 'message': track_file = self.medialist.selected_track()['text'] else: track_file = Show.base_complete_path( self, self.medialist.selected_track()['location']) # print "!!!!! artshow load next ",track_file self.mon.trace(self, track_file) self.next_player.load(track_file, self.loaded_callback, enable_menu=False)
def end_shower(self, show_id, reason, message): self.mon.log( self, self.show_params["show-ref"] + " " + str(self.show_id) + ": Returned from shower with " + reason + " " + message, ) self.sr.hide_click_areas(self.controls_list) self.req_next = reason Show.base_end_shower(self) self.what_next_after_showing()
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): """ show_id - index of the top level show caling this (for debug only) show_params - dictionary section for the menu canvas - the canvas that the menu is to be written on showlist - the showlist pp_dir - Pi Presents directory pp_home - Pi presents data_home directory pp_profile - Pi presents profile directory """ # init the common bits Show.base__init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback) # instatiatate the screen driver - used only to access enable and hide click areas self.sr=ScreenDriver() # create an instance of PathManager - only used to parse the links. self.path = PathManager() self.allowed_links=('play','pause','exit','return','null','no-command','stop') # init variables self.links=[] self.track_timeout_timer=None self.show_timeout_timer=None self.next_track_signal=False self.current_track_ref='' self.req_next=''
def track_ready_callback(self, enable_show_background): self.delete_eggtimer() if self.show_params["disable-controls"] != "yes": # merge controls from the track controls_text = self.current_player.get_links() reason, message, track_controls = self.controlsmanager.parse_controls(controls_text) if reason == "error": self.mon.err(self, message + " in track: " + self.current_player.track_params["track-ref"]) self.req_next = "error" self.what_next_after_showing() self.controlsmanager.merge_controls(self.controls_list, track_controls) self.sr.enable_click_areas(self.controls_list) Show.base_track_ready_callback(self, enable_show_background)
def what_to_load_next(self): self.mon.trace(self,self.pretty_state ()) # closing down so don't load anything if self.ending_reason in ('killed','error'): return # wanting to exit so don't load just skip to what-next if self.terminate_signal is True or self.exit_signal is True or self.req_next=='error': self.what_next() # has content of list been changed (replaced if it has, used for content of livelist) if self.medialist.replace_if_changed() is True: self.ending_reason='change-medialist' self.close_current_and_next() else: # get the next track and init player self.medialist.next(self.show_params['sequence']) if self.medialist.at_end() is True: self.end_medialist_warning=True # print "!!!!! artshow init next " self.next_player=Show.base_init_selected_player(self,self.medialist.selected_track()) if self.next_player is None: self.mon.err(self,"Track Type cannot be played by this show: "+self.medialist.selected_track()['type']) self.req_next='error' self.what_next() else: # and load the next after a wait to allow animation etc to be timely. self.canvas.after(self.load_delay,self.load_next)
def play(self,end_callback,show_ready_callback, parent_kickback_signal,level,controls_list): self.mon.trace(self,self.show_params['show-ref']) Show.base_play(self,end_callback,show_ready_callback,parent_kickback_signal, level,controls_list) if self.medialist.anon_length()==0 and self.show_params['type'] not in ('liveshow','artliveshow'): self.mon.err(self,'No anonymous tracks in medialist ') self.end('error','No anonymous tracks in medialist ') # get the previous shower and player from calling show # Show.base_get_previous_player_from_parent(self) # and delete eggtimer started by the parent if self.previous_shower is not None: self.previous_shower.delete_eggtimer() self.wait_for_trigger()
def track_ready_callback(self,enable_show_background): self.delete_eggtimer() if self.show_params['disable-controls'] != 'yes': #merge controls from the track controls_text=self.current_player.get_links() reason,message,track_controls=self.controlsmanager.parse_controls(controls_text) if reason == 'error': self.mon.err(self,message + " in track: "+ self.current_player.track_params['track-ref']) self.req_next='error' self.what_next_after_showing() self.controlsmanager.merge_controls(self.controls_list,track_controls) self.sr.enable_click_areas(self.controls_list) Show.base_track_ready_callback(self,enable_show_background)
def __init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback): # init the common bits Show.base__init__(self, show_id, show_params, root, canvas, showlist, pp_dir, pp_home, pp_profile, command_callback) # instatiatate the screen driver - used only to access enable and hide click areas self.sr = ScreenDriver() # create an instance of PathManager - only used to parse the links. self.path = PathManager() self.allowed_links = ('play', 'pause', 'exit', 'return', 'null', 'no-command', 'stop') # init variables self.links = [] self.track_timeout_timer = None self.show_timeout_timer = None self.next_track_signal = False self.current_track_ref = '' self.req_next = '' self.controlsmanager = ControlsManager() # Init variables special to this show self.poll_for_interval_timer = None self.interval_timer_signal = False self.waiting_for_interval = False self.interval_timer = None self.duration_timer = None self.end_trigger_signal = False self.next_track_signal = False self.previous_track_signal = False self.play_child_signal = False self.error_signal = False self.show_timeout_signal = False self.req_next = 'nil' self.state = 'closed' self.count = 0 self.interval = 0 self.duration = 0 self.controls_list = [] self.enable_hint = True
def start_load_show_loop(self, selected_track): # shuffle players Show.base_shuffle(self) self.delete_eggtimer() # is child track required if self.show_params['child-track-ref'] != '': self.enable_child = True else: self.enable_child = False # load the track or show # params - track,enable_menu enable = self.enable_child & self.enable_hint Show.base_load_track_or_show(self, selected_track, self.what_next_after_load, self.end_shower, enable)
def start_load_show_loop(self,selected_track): # shuffle players Show.base_shuffle(self) self.delete_eggtimer() # is child track required if self.show_params['child-track-ref'] != '': self.enable_child=True else: self.enable_child=False # load the track or show # params - track,enable_menu enable=self.enable_child & self.enable_hint Show.base_load_track_or_show(self,selected_track,self.what_next_after_load,self.end_shower,enable)
def what_to_load_next(self): self.mon.trace(self,self.pretty_state ()) # closing down so don't load anything if self.ending_reason in ('killed','error'): return # wanting to exit so don't load just skip to what-next if self.terminate_signal is True or self.exit_signal is True or self.req_next=='error': self.what_next() # has content of list been changed (replaced if it has, used for content of livelist) # print 'WHAT to load NEXT' self.medialist.create_new_livelist() # print result, self.medialist.new_length(),self.medialist.anon_length() if self.medialist.livelist_changed() is True: # print 'ITS CHANGED' self.ending_reason='change-medialist' self.close_current_and_next() else: # get the next track and init player self.medialist.next(self.show_params['sequence']) Show.delete_admin_message(self) if self.medialist.at_end() is True: self.end_medialist_warning=True # print "!!!!! artshow init next " self.next_player=Show.base_init_selected_player(self,self.medialist.selected_track()) if self.next_player is None: self.mon.err(self,"Track Type cannot be played by this show: "+self.medialist.selected_track()['type']) self.req_next='error' self.what_next() else: # load the next track while current is showing # messageplayer passes the text not a file name if self.medialist.selected_track()['type'] == 'message': track_file=self.medialist.selected_track()['text'] else: track_file=Show.base_complete_path(self,self.medialist.selected_track()['location']) # print "!!!!! artshow load next ",track_file self.mon.trace(self, track_file) self.next_player.load(track_file, self.loaded_callback, enable_menu=False)
def start_load_show_loop(self, selected_track): # shuffle players Show.base_shuffle(self) self.mon.trace(self, '') self.display_eggtimer() # start the show timer when displaying the first track if self.current_track_ref == self.first_track_ref: if self.show_timeout_timer is not None: self.canvas.after_cancel(self.show_timeout_timer) self.show_timeout_timer = None if self.show_timeout != 0: self.show_timeout_timer = self.canvas.after( self.show_timeout * 1000, self.show_timeout_stop) # start timeout for the track if required ???? differnet to radiobuttonshow if self.continue_timeout is False: if self.track_timeout_timer is not None: self.canvas.after_cancel(self.track_timeout_timer) self.track_timeout_timer = None if self.current_track_ref != self.first_track_ref and self.track_timeout != 0: # print ('KRT set track timeout timer') self.track_timeout_timer = self.canvas.after( self.track_timeout * 1000, self.track_timeout_callback) # get control bindings for this show # needs to be done for each track as track can override the show controls # read the show links. Track links will be added by track_ready_callback if self.show_params['disable-controls'] == 'yes': self.links = [] else: reason, message, self.links = self.path.parse_links( self.show_params['links'], self.allowed_links) if reason == 'error': self.mon.err(self, message + " in show") self.end('error', message + " in show") # load the track or show # params - track,, track loaded callback, end eshoer callback,enable_menu Show.base_load_track_or_show(self, selected_track, self.what_next_after_load, self.end_shower, False)
def start_load_show_loop(self,selected_track): # shuffle players Show.base_shuffle(self) self.mon.trace(self,'') self.display_eggtimer() # get control bindings for this show # needs to be done for each track as track can override the show controls if self.show_params['disable-controls'] == 'yes': self.controls_list=[] else: reason,message,self.controls_list= self.controlsmanager.get_controls(self.show_params['controls']) if reason=='error': self.mon.err(self,message) self.end('error',"error in controls") return # load the track or show Show.base_load_track_or_show(self,selected_track,self.what_next_after_load,self.end_shower,False)
def start_load_show_loop(self, selected_track): # shuffle players Show.base_shuffle(self) self.mon.trace(self, "") self.display_eggtimer() # get control bindings for this show # needs to be done for each track as track can override the show controls if self.show_params["disable-controls"] == "yes": self.controls_list = [] else: reason, message, self.controls_list = self.controlsmanager.get_controls(self.show_params["controls"]) if reason == "error": self.mon.err(self, message) self.end("error", "error in controls") return # load the track or show Show.base_load_track_or_show(self, selected_track, self.what_next_after_load, self.end_shower, False)
def track_ready_callback(self,enable_show_background): self.delete_eggtimer() # print 'TRACK READY CALLBACK' # print 'previous is',self.mon.id(self.previous_player), self.next_track_signal #merge links from the track if self.show_params['disable-controls'] == 'yes': track_links=[] else: reason,message,track_links=self.path.parse_links(self.current_player.get_links(),self.allowed_links) if reason == 'error': self.mon.err(self,message + " in track: "+ self.current_player.track_params['track-ref']) self.req_next='error' self.what_next_after_showing() self.path.merge_links(self.links,track_links) # enable the click-area that are in the list of links self.sr.enable_click_areas(self.links) Show.base_track_ready_callback(self,enable_show_background)