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
                Show.write_stats(self, 'play', self.show_params,
                                 self.medialist.track(index))
                self.start_load_show_loop(self.medialist.track(index))
            else:
                self.mon.err(
                    self, "track reference not found in medialist: " +
                    self.current_track_ref)
                self.end(
                    'error', "track reference not found in medialist: " +
                    self.current_track_ref)

        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 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
                Show.write_stats(self,'play',self.show_params,self.medialist.track(index))
                self.start_load_show_loop(self.medialist.track(index))
            else:
                self.mon.err(self,"track reference not found in medialist: "+ self.current_track_ref)
                self.end('error',"track reference not found in medialist: "+ self.current_track_ref)
                    
        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()
示例#3
0
    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.last_menu_index = self.menu_index
            Show.write_stats(self, 'play', self.show_params, self.next_track)
            self.start_load_show_loop(self.next_track)

        else:
            # no stopping the show required so re-display the menu
            self.do_menu_track()
示例#4
0
    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.last_menu_index=self.menu_index
            Show.write_stats(self,'play',self.show_params,self.next_track)
            self.start_load_show_loop(self.next_track)
            
        else:
            # no stopping the show required so re-display the menu
            self.do_menu_track()
示例#5
0
    def what_next_after_showing(self):
        # print 'WHAT NEXT'
        self.mon.trace(self,self.pretty_what_next_after_showing_state())
                        
        self.track_count+=1
        # set false when child rack is to be played
        self.enable_hint=True

        # first of all deal with conditions that do not require the next track to be shown
        # some of the conditions can happen at any time, others only when a track is closed or at pause_at_end

        # need to terminate
        if self.terminate_signal is True:
            self.terminate_signal=False
            self.stop_timers()
            # set what to do after closed or unloaded
            self.ending_reason='killed'
            Show.base_close_or_unload(self)

        elif self.error_signal== True or self.req_next=='error':
            self.error_signal=False
            self.req_next=''
            self.stop_timers()
            # set what to do after closed or unloaded
            self.ending_reason='error'
            Show.base_close_or_unload(self)

        # used for exiting show from other shows, time of day, external etc.
        elif self.exit_signal is True:
            self.exit_signal=False
            self.stop_timers()
            self.ending_reason='exit'
            Show.base_close_or_unload(self)

        #  show timeout
        elif self.show_timeout_signal is True:
            self.show_timeout_signal=False
            self.stop_timers()
            self.ending_reason='user-stop'
            Show.base_close_or_unload(self)

        # user wants to stop the show
        elif self.user_stop_signal is True:
            self.user_stop_signal=False
            # print 'user stop'
            self.stop_timers()
            self.ending_reason='user-stop'
            Show.base_close_or_unload(self)


       # interval > 0. If last track has finished we are waiting for interval timer before ending the list
       # note: if medialist finishes after interval is up then this route is used to start trigger. 
        elif self.waiting_for_interval is True:
            # interval_timer_signal set by alarm clock started in start_list
            if self.interval_timer_signal is True:
                self.interval_timer_signal=False
                self.waiting_for_interval=False
                # print 'RECEIVED INTERVAL TIMER SIGNAL'
                if self.show_params['repeat']=='repeat':
                    self.wait_for_trigger()
                else:
                    self.stop_timers()
                    self.ending_reason='user-stop'
                    Show.base_close_or_unload(self)
            else:
                self.poll_for_interval_timer=self.canvas.after(1000,self.what_next_after_showing)

        else:
            self.medialist.create_new_livelist()
            escapetrack_required=self.escapetrack_required
            self.escapetrack_required=False
            # print escapetrack_required,self.medialist.new_length()
            if escapetrack_required is True and self.medialist.new_length() == 0:
                # print 'use escape track'
                index = self.medialist.index_of_track(self.show_params['escape-track-ref'])
                self.mon.log(self,'Starting Escape Track: '+ self.show_params['escape-track-ref'])
                if index >=0:
                    # don't use select the track as need to preserve mediashow sequence for returning from esacpe track
                    escape_track=self.medialist.track(index)
                    Show.write_stats(self,'play escape track',self.show_params,escape_track)
                    self.display_eggtimer()
                    # use new empty livelist so if changed works OK when return from empty track
                    self.medialist.use_new_livelist()
                    self.start_load_show_loop(escape_track)
                else:
                    self.mon.err(self,"Escape Track empty")
                    self.end('error',"Escape Track empty")

            # print 'FOR IF CHANGED',self.first_list,self.medialist.length(),self.medialist.new_length(),self.medialist.livelist_changed()
            elif self.first_list is True or self.medialist.livelist_changed() is True or (self.medialist.length() == 0 and self.medialist.new_length() == 0):                            

                if self.first_list is False:
                    # do show control
                    if self.medialist.length() == 0 and self.medialist.new_length() != 0:
                            # print 'show control empty to not empty'
                            # do show control when goes from not empty to empty only
                            self.show_control(self.show_params['show-control-not-empty'])
                            
                    elif self.medialist.length() != 0 and self.medialist.new_length() == 0:
                            # print 'show control not empty to empty'
                            # do show control when goes from empty to not empty only
                            self.show_control(self.show_params['show-control-empty'])  

                self.first_list=False
                
                if self.medialist.new_length()==0 and self.show_params['repeat']=='repeat':
                    # start empty track/show
                    index = self.medialist.index_of_track(self.show_params['empty-track-ref'])
                    self.mon.log(self,'Starting Empty Track: '+ self.show_params['empty-track-ref'])
                    if index >=0:
                        # don't use select the track as need to preserve mediashow sequence for returning from empty track/show
                        empty_track=self.medialist.track(index)
                        # print 'play empty track', empty_track['title'],empty_track['type']
                        Show.write_stats(self,'play empty track',self.show_params,empty_track)
                        if empty_track['type'] =='show':
                            self.escapetrack_required=True
                        
                        self.display_eggtimer()
                        # use new empty livelist so if changed works OK when return from empty track
                        self.medialist.use_new_livelist()
                        self.start_load_show_loop(empty_track)
                    else:
                        self.mon.err(self,"List Empty Track not specified")
                        self.end('error',"List Empty Track not specified")
  

                elif self.medialist.new_length()==0 and self.show_params['repeat']=='single-run':
                    if self.level != 0:
                        self.kickback_for_next_track=False
                        self.subshow_kickback_signal=False
                        self.end('normal',"End of single run - Return from Sub Show")
                    else:
                        # end of single run and at top - exit the show
                        self.stop_timers()
                        self.ending_reason='user-stop'
                        Show.base_close_or_unload(self)

                else:
                    #changed but new is not zero
                    self.medialist.use_new_livelist()
                    # print 'livelist changed and not empty'
                    self.start_list()               


            # otherwise consider operation that might show the next track          
            else:
                # print 'ELSE',self.medialist.at_end()
                # report error if medilaist is empty (liveshow will not get this far
                if self.medialist.length()==0:
                    self.mon.err(self,"Medialist empty")
                    self.end('error',"Medialist empty")
                    
                # setup default direction for next track as normally goes forward unless kicked back
                self.kickback_for_next_track=False
                # print 'init direction to False at begin of what_next_after showing', self.kickback_for_next_track
                # end trigger from input, or track count
                if self.end_trigger_signal is True or (self.track_count_limit >0  and self.track_count == self.track_count_limit):
                    self.end_trigger_signal=False
                    # repeat so test start trigger
                    if self.show_params['repeat'] == 'repeat':
                        self.stop_timers()
                        # print 'END TRIGGER restart'
                        self.wait_for_trigger()
                    else:
                        # single run so exit show
                        if self.level != 0:
                            self.kickback_for_next_track=False
                            self.subshow_kickback_signal=False
                            # print 'single run exit subshow'
                            self.end('normal',"End of single run - Return from Sub Show")
                        else:
                            # end of single run and at top - exit the show
                            self.stop_timers()
                            # print 'ENDING'
                            self.ending_reason='user-stop'
                            Show.base_close_or_unload(self)                   

                # user wants to play child
                elif self.play_child_signal is True:
                    self.play_child_signal=False
                    index = self.medialist.index_of_track(self.child_track_ref)
                    if index >=0:
                        # don't use select the track as need to preserve mediashow sequence for returning from child
                        child_track=self.medialist.track(index)
                        Show.write_stats(self,'play child',self.show_params,child_track)
                        self.display_eggtimer()
                        self.enable_hint=False
                        self.start_load_show_loop(child_track)
                    else:
                        self.mon.err(self,"Child not found in medialist: "+ self.child_track_ref)
                        self.ending_reason='error'
                        Show.base_close_or_unload(self)



                # skip to next track on user input or after subshow
                elif self.next_track_signal is True:
                    # print 'skip forward test' ,self.subshow_kickback_signal
                    if self.next_track_signal is True or self.subshow_kickback_signal is False:
                        self.next_track_signal=False
                        self.kickback_for_next_track=False
                        if self.medialist.at_end() is True:
                            # medialist_at_end can give false positive for shuffle
                            if  self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'repeat':
                                self.wait_for_trigger()
                            elif  self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'single-run':
                                if self.level != 0:
                                    self.kickback_for_next_track=False
                                    self.subshow_kickback_signal=False
                                    # print 'end subshow skip forward test, self. direction is ' ,self.kickback_for_next_track
                                    self.end('normal',"Return from Sub Show")
                                else:
                                    # end of single run and at top - exit the show
                                    self.stop_timers()
                                    self.ending_reason='user-stop'
                                    Show.base_close_or_unload(self)
                            else:
                                # shuffling  - just do next track
                                self.kickback_for_next_track=False
                                self.medialist.next(self.show_params['sequence'])
                                self.start_load_show_loop(self.medialist.selected_track())      
                        else:
                            # not at end just do next track
                            self.medialist.next(self.show_params['sequence'])
                            self.start_load_show_loop(self.medialist.selected_track())


                # skip to previous track on user input or after subshow
                elif self.previous_track_signal is True or self.subshow_kickback_signal is True:
                    # print 'skip backward test, subshow kickback is' ,self.subshow_kickback_signal
                    self.subshow_kickback_signal=False
                    self.previous_track_signal=False
                    self.kickback_for_next_track=True
                    # medialist_at_start can give false positive for shuffle
                    if self.medialist.at_start() is True:
                        # print 'AT START'
                        if  self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'repeat':
                            self.kickback_for_next_track=True
                            self.wait_for_trigger()
                        elif  self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'single-run':
                            if self.level != 0:
                                self.kickback_for_next_track=True
                                self.subshow_kickback_signal=True
                                # print 'end subshow skip forward test, self. direction is ' ,self.kickback_for_next_track
                                self.end('normal',"Return from Sub Show")
                            else:
                                # end of single run and at top - exit the show
                                self.stop_timers()
                                self.ending_reason='user-stop'
                                Show.base_close_or_unload(self)
                        else:
                            # shuffling  - just do previous track
                            self.kickback_for_next_track=True
                            self.medialist.previous(self.show_params['sequence'])
                            self.start_load_show_loop(self.medialist.selected_track())               
                    else:
                        # not at end just do next track
                        self.medialist.previous(self.show_params['sequence'])              
                        self.start_load_show_loop(self.medialist.selected_track())


                    

                # AT END OF MEDIALIST
                elif self.medialist.at_end() is True:
                    # print 'MEDIALIST AT END'

                    # interval>0 and list finished so wait for the interval timer
                    if self.show_params['sequence'] == "ordered"  and self.interval > 0 and self.interval_timer_signal==False:
                        self.waiting_for_interval=True
                        # print 'WAITING FOR INTERVAL'
                        Show.base_shuffle(self)
                        Show.base_track_ready_callback(self,False)
                        self.poll_for_interval_timer=self.canvas.after(200,self.what_next_after_showing) 

                    # interval=0   
                    #elif self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'repeat' and self.show_params['trigger-end-type']== 'interval' and int(self.show_params['trigger-end-param']) == 0:
                        #self.medialist.next(self.show_params['sequence'])
                        # self.start_load_show_loop(self.medialist.selected_track())

                    # shuffling so there is no end condition, get out of end test
                    elif self.show_params['sequence'] == "shuffle":
                        self.medialist.next(self.show_params['sequence'])
                        self.start_load_show_loop(self.medialist.selected_track())
                        
                    # nothing special to do at end of list, just repeat or exit
                    elif self.show_params['sequence'] == "ordered":
                        if self.show_params['repeat'] == 'repeat':
                            # print 'repeating at end of list'
                            self.wait_for_trigger()
                        else:
                            # single run
                            # if not at top return to parent
                            if self.level !=0:
                                self.end('normal',"End of Single Run")
                            else:
                                # at top so close the show
                                # print 'closing show'
                                self.stop_timers()
                                self.ending_reason='user-stop'
                                Show.base_close_or_unload(self)
                            
                    else:
                        self.mon.err(self,"Unhandled playing event at end of list: "+self.show_params['sequence'] +' with ' + self.show_params['repeat']+" of "+ self.show_params['trigger-end-param'])
                        self.end('error',"Unhandled playing event at end of list: "+self.show_params['sequence'] +' with ' + self.show_params['repeat']+" of "+ self.show_params['trigger-end-param'])
                    
                elif self.medialist.at_end() is False:
                    # nothing special just do the next track
                    # print 'nothing special'
                    self.medialist.next(self.show_params['sequence'])
                    self.start_load_show_loop(self.medialist.selected_track())
                          
                else:
                    # unhandled state
                    self.mon.err(self,"Unhandled playing event: "+self.show_params['sequence'] +' with ' + self.show_params['repeat']+" of "+ self.show_params['trigger-end-param'])
                    self.end('error',"Unhandled playing event: "+self.show_params['sequence'] +' with ' + self.show_params['repeat']+" of "+ self.show_params['trigger-end-param'])
示例#6
0
    def what_next_after_showing(self):
        self.mon.trace(self,self.pretty_what_next_after_showing_state())
                        
        self.track_count+=1
        # set false when child rack is to be played
        self.enable_hint=True

        # first of all deal with conditions that do not require the next track to be shown
        # some of the conditions can happen at any time, others only when a track is closed or at pause_at_end

        # need to terminate
        if self.terminate_signal is True:
            self.terminate_signal=False
            self.stop_timers()
            # set what to do after closed or unloaded
            self.ending_reason='killed'
            Show.base_close_or_unload(self)

        elif self.error_signal== True or self.req_next=='error':
            self.error_signal=False
            self.req_next=''
            self.stop_timers()
            # set what to do after closed or unloaded
            self.ending_reason='error'
            Show.base_close_or_unload(self)

        # used for exiting show from other shows, time of day, external etc.
        elif self.exit_signal is True:
            self.exit_signal=False
            self.stop_timers()
            self.ending_reason='exit'
            Show.base_close_or_unload(self)

        #  show timeout
        elif self.show_timeout_signal is True:
            self.show_timeout_signal=False
            self.stop_timers()
            self.ending_reason='user-stop'
            Show.base_close_or_unload(self)

        # user wants to stop the show
        elif self.user_stop_signal is True:
            self.user_stop_signal=False
            self.stop_timers()
            self.ending_reason='user-stop'
            Show.base_close_or_unload(self)


       # interval > 0. If last track has finished we are waiting for interval timer before ending the list
       # note: if medialist finishes after interval is up then this route is used to start trigger. 
        elif self.waiting_for_interval is True:
            # interval_timer_signal set by alarm clock started in start_list
            if self.interval_timer_signal is True:
                self.interval_timer_signal=False
                self.waiting_for_interval=False
                # print 'RECEIVED INTERVAL TIMER SIGNAL'
                if self.show_params['repeat']=='repeat':
                    self.wait_for_trigger()
                else:
                    self.stop_timers()
                    self.ending_reason='user-stop'
                    Show.base_close_or_unload(self)
            else:
                self.poll_for_interval_timer=self.canvas.after(1000,self.what_next_after_showing)
                                                 
  

        # has content of list been changed (replaced if it has, used for content of livelist)
        # causes it to go to wait_for_trigger and start_list
        #not sure why need clos_and_unload here ???????
        elif self.medialist.replace_if_changed() is True:
            self.ending_reason='change-medialist'
            # print 'CHANGE REQ'
            Show.base_close_or_unload(self)


        # otherwise consider operation that might show the next track          
        else:
            # setup default direction for next track as normally goes forward unless kicked back
            self.kickback_for_next_track=False
            # print 'init direction to False at begin of what_next_after showing', self.kickback_for_next_track
            # end trigger from input, or track count
            if self.end_trigger_signal is True or (self.track_count_limit >0  and self.track_count == self.track_count_limit):
                self.end_trigger_signal=False
                # repeat so test start trigger
                if self.show_params['repeat'] == 'repeat':
                    self.stop_timers()
                    # print 'END TRIGGER restart'
                    self.wait_for_trigger()
                else:
                    # single run so exit show
                    if self.level != 0:
                        self.kickback_for_next_track=False
                        self.subshow_kickback_signal=False
                        self.end('normal',"End of single run - Return from Sub Show")
                    else:
                        # end of single run and at top - exit the show
                        self.stop_timers()
                        self.ending_reason='user-stop'
                        Show.base_close_or_unload(self)                   

            # user wants to play child
            elif self.play_child_signal is True:
                self.play_child_signal=False
                index = self.medialist.index_of_track(self.child_track_ref)
                if index >=0:
                    # don't use select the track as need to preserve mediashow sequence for returning from child
                    child_track=self.medialist.track(index)
                    Show.write_stats(self,'play child',self.show_params,child_track)
                    self.display_eggtimer()
                    self.enable_hint=False
                    self.start_load_show_loop(child_track)
                else:
                    self.mon.err(self,"Child not found in medialist: "+ self.child_track_ref)
                    self.ending_reason='error'
                    Show.base_close_or_unload(self)



            # skip to next track on user input or after subshow
            elif self.next_track_signal is True:
                # print 'skip forward test' ,self.subshow_kickback_signal
                if self.next_track_signal is True or self.subshow_kickback_signal is False:
                    self.next_track_signal=False
                    self.kickback_for_next_track=False
                    if self.medialist.at_end() is True:
                        # medialist_at_end can give false positive for shuffle
                        if  self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'repeat':
                            self.wait_for_trigger()
                        elif  self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'single-run':
                            if self.level != 0:
                                self.kickback_for_next_track=False
                                self.subshow_kickback_signal=False
                                # print 'end subshow skip forward test, self. direction is ' ,self.kickback_for_next_track
                                self.end('normal',"Return from Sub Show")
                            else:
                                # end of single run and at top - exit the show
                                self.stop_timers()
                                self.ending_reason='user-stop'
                                Show.base_close_or_unload(self)
                        else:
                            # shuffling  - just do next track
                            self.kickback_for_next_track=False
                            self.medialist.next(self.show_params['sequence'])
                            self.start_load_show_loop(self.medialist.selected_track())      
                    else:
                        # not at end just do next track
                        self.medialist.next(self.show_params['sequence'])
                        self.start_load_show_loop(self.medialist.selected_track())


            # skip to previous track on user input or after subshow
            elif self.previous_track_signal is True or self.subshow_kickback_signal is True:
                # print 'skip backward test, subshow kickback is' ,self.subshow_kickback_signal
                self.subshow_kickback_signal=False
                self.previous_track_signal=False
                self.kickback_for_next_track=True
                # medialist_at_start can give false positive for shuffle
                if self.medialist.at_start() is True:
                    # print 'AT START'
                    if  self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'repeat':
                        self.kickback_for_next_track=True
                        self.wait_for_trigger()
                    elif  self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'single-run':
                        if self.level != 0:
                            self.kickback_for_next_track=True
                            self.subshow_kickback_signal=True
                            # print 'end subshow skip forward test, self. direction is ' ,self.kickback_for_next_track
                            self.end('normal',"Return from Sub Show")
                        else:
                            # end of single run and at top - exit the show
                            self.stop_timers()
                            self.ending_reason='user-stop'
                            Show.base_close_or_unload(self)
                    else:
                        # shuffling  - just do previous track
                        self.kickback_for_next_track=True
                        self.medialist.previous(self.show_params['sequence'])
                        self.start_load_show_loop(self.medialist.selected_track())               
                else:
                    # not at end just do next track
                    self.medialist.previous(self.show_params['sequence'])              
                    self.start_load_show_loop(self.medialist.selected_track())


                

            # AT END OF MEDIALIST
            elif self.medialist.at_end() is True:
                # print 'MEDIALIST AT END'

                # interval>0 and list finished so wait for the interval timer
                if self.show_params['sequence'] == "ordered"  and self.interval > 0 and self.interval_timer_signal==False:
                    self.waiting_for_interval=True
                    # print 'WAITING FOR INTERVAL'
                    Show.base_shuffle(self)
                    Show.base_track_ready_callback(self,False)
                    self.poll_for_interval_timer=self.canvas.after(200,self.what_next_after_showing) 

                # interval=0   
                #elif self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'repeat' and self.show_params['trigger-end-type']== 'interval' and int(self.show_params['trigger-end-param']) == 0:
                    #self.medialist.next(self.show_params['sequence'])
                    # self.start_load_show_loop(self.medialist.selected_track())

                # shuffling so there is no end condition, get out of end test
                elif self.show_params['sequence'] == "shuffle":
                    self.medialist.next(self.show_params['sequence'])
                    self.start_load_show_loop(self.medialist.selected_track())
                    
                # nothing special to do at end of list, just repeat or exit
                elif self.show_params['sequence'] == "ordered":
                    if self.show_params['repeat'] == 'repeat':
                        self.wait_for_trigger()
                    else:
                        # single run
                        # if not at top return to parent
                        if self.level !=0:
                            self.end('normal',"End of Single Run")
                        else:
                            # at top so close the show
                            self.stop_timers()
                            self.ending_reason='user-stop'
                            Show.base_close_or_unload(self)
                        
                else:
                    self.mon.err(self,"Unhandled playing event at end of list: "+self.show_params['sequence'] +' with ' + self.show_params['repeat']+" of "+ self.show_params['trigger-end-param'])
                    self.end('error',"Unhandled playing event at end of list: "+self.show_params['sequence'] +' with ' + self.show_params['repeat']+" of "+ self.show_params['trigger-end-param'])
                
            elif self.medialist.at_end() is False:
                # nothing special just do the next track
                self.medialist.next(self.show_params['sequence'])
                self.start_load_show_loop(self.medialist.selected_track())
                      
            else:
                # unhandled state
                self.mon.err(self,"Unhandled playing event: "+self.show_params['sequence'] +' with ' + self.show_params['repeat']+" of "+ self.show_params['trigger-end-param'])
                self.end('error',"Unhandled playing event: "+self.show_params['sequence'] +' with ' + self.show_params['repeat']+" of "+ self.show_params['trigger-end-param'])
    def what_next_after_showing(self):
        self.mon.trace(self, '')
        # 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.continue_timeout=False

            # home
            if self.next_track_op in ('home'):
                # back to 1 before home
                back_ref=self.path.back_to(self.home_track_ref)
                if back_ref == '':
                    self.mon.err(self,"home - home track not in path: "+self.home_track_ref)
                    self.end('error',"home - home track not in path: "+self.home_track_ref)
                # play home
                self.next_track_ref=self.home_track_ref
                self.path.append(self.next_track_ref)
                if self.debug: print 'Executed Home ' + self.path.pretty_path()

            # return-by
            elif self.next_track_op in ('return-by'):
                if self.current_track_ref != self.home_track_ref:
                    # back n stopping at home
                    # back one more and return it
                    back_ref=self.path.back_by(self.home_track_ref,self.next_track_arg)
                    # use returned track
                    self.next_track_ref=back_ref
                    self.path.append(self.next_track_ref)
                    if self.debug: print 'Executed Return By' + self.next_track_arg + self.path.pretty_path()

            # repeat is return by 1
            elif self.next_track_op in ('repeat'):
                # print 'current', self.current_track_ref
                # print 'home', self.home_track_ref
                self.path.pop_for_sibling()
                self.next_track_ref=self.current_track_ref
                self.path.append(self.current_track_ref)
                self.continue_timeout=True
                if self.debug: print 'Executed Repeat ' + self.path.pretty_path()

            # return-to
            elif self.next_track_op in ('return-to'):
                # back to one before return-to track
                back_ref=self.path.back_to(self.next_track_arg)
                if back_ref == '':
                    self.mon.err(self,"return-to - track not in path: "+self.next_track_arg)
                    self.end('error',"return-to - track not in path: "+self.next_track_arg)
                # and append the return to track
                self.next_track_ref=self.next_track_arg
                self.path.append(self.next_track_ref)
                if self.debug: print 'Executed Return To' + self.next_track_arg + self.path.pretty_path()
                
            # call
            elif self.next_track_op in ('call'):
                # append the required track
                self.path.append(self.next_track_arg)
                self.next_track_ref=self.next_track_arg
                if self.debug: print 'Executed Call ' + self.next_track_arg + self.path.pretty_path()

            # goto
            elif self.next_track_op in ('goto'):
                self.path.empty()
                # add the goto track
                self.next_track_ref=self.next_track_arg
                self.path.append(self.next_track_arg)
                if self.debug: print 'Executed Goto ' + self.next_track_arg + self.path.pretty_path()

            # jump
            elif self.next_track_op in ('jump'):
                # back to home and remove it
                back_ref=self.path.back_to(self.home_track_ref)
                if back_ref == '':
                    self.mon.err(self,"jump - home track not in path: "+self.home_track_ref)
                    self.end('error',"jump - track not in path: "+self.home_track_ref)
                # add back the home track without playing it
                self.path.append(self.home_track_ref)
                # append the jumped to track
                self.next_track_ref=self.next_track_arg
                self.path.append(self.next_track_ref)
                if self.debug: print 'Executed Jump ' + self.next_track_arg + self.path.pretty_path()

            else:
                self.mon.err(self,"unaddressed what next: "+ self.next_track_op+ ' '+self.next_track_arg)
                self.end('error',"unaddressed what next: " + self.next_track_op+ ' '+self.next_track_arg)
            
            self.current_track_ref=self.next_track_ref                    
            index = self.medialist.index_of_track(self.next_track_ref)
            if index >=0:
                Show.write_stats(self,self.next_track_op,self.show_params,self.medialist.track(index))
                # don't use select the track as not using selected_track in hyperlinkshow
                self.start_load_show_loop(self.medialist.track(index))

            else:
                self.mon.err(self,"next-track not found in medialist: "+ self.next_track_ref)
                self.end('error',"next track not found in medialist: "+ self.next_track_ref)
                
        else:
            # track ends naturally look to see if there is a pp-onend link
            found,link_op,link_arg=self.path.find_link('pp-onend',self.links)
            if found is True:
                if link_op=='exit':
                    self.user_stop_signal=True                   
                    self.current_player.input_pressed('stop')
                    self.what_next_after_showing()
                elif link_op == 'home':
                    self.decode_home()
                    self.what_next_after_showing()
                elif link_op  == 'return':
                    self.decode_return(link_arg)
                    self.what_next_after_showing()
                elif link_op  == 'call':
                    self.decode_call(link_arg)
                    self.what_next_after_showing()
                elif link_op  == 'goto':
                    self.decode_goto(link_arg)
                    self.what_next_after_showing()
                elif link_op  == 'jump':
                    self.decode_jump(link_arg)
                    self.what_next_after_showing()
                elif link_op  ==  'repeat':
                    self.decode_repeat()
                    self.what_next_after_showing() 
                else:
                    self.mon.err(self,"unknown link command for pp_onend: "+ link_op)
                    self.end('error',"unkown link command for pp-onend: "+ link_op)
            else:
                if self.show_params['disable-controls']!='yes':
                    self.mon.err(self,"pp-onend for this track not found: "+ link_op)
                    self.end('error',"pp-onend for this track not found: "+ link_op)
示例#8
0
    def what_next_after_showing(self):
        self.mon.trace(self, self.pretty_what_next_after_showing_state())

        self.track_count += 1
        # set false when child rack is to be played
        self.enable_hint = True

        # first of all deal with conditions that do not require the next track to be shown
        # some of the conditions can happen at any time, others only when a track is closed or at pause_at_end

        # need to terminate
        if self.terminate_signal is True:
            self.terminate_signal = False
            self.stop_timers()
            # set what to do after closed or unloaded
            self.ending_reason = 'killed'
            Show.base_close_or_unload(self)

        elif self.error_signal == True or self.req_next == 'error':
            self.error_signal = False
            self.req_next = ''
            self.stop_timers()
            # set what to do after closed or unloaded
            self.ending_reason = 'error'
            Show.base_close_or_unload(self)

        # used for exiting show from other shows, time of day, external etc.
        elif self.exit_signal is True:
            self.exit_signal = False
            self.stop_timers()
            self.ending_reason = 'exit'
            Show.base_close_or_unload(self)

        #  show timeout
        elif self.show_timeout_signal is True:
            self.show_timeout_signal = False
            self.stop_timers()
            self.ending_reason = 'user-stop'
            Show.base_close_or_unload(self)

        # user wants to stop the show
        elif self.user_stop_signal is True:
            self.user_stop_signal = False
            self.stop_timers()
            self.ending_reason = 'user-stop'
            Show.base_close_or_unload(self)

    # interval > 0. If last track has finished we are waiting for interval timer before ending the list
    # note: if medialist finishes after interval is up then this route is used to start trigger.
        elif self.waiting_for_interval is True:
            # interval_timer_signal set by alarm clock started in start_list
            if self.interval_timer_signal is True:
                self.interval_timer_signal = False
                self.waiting_for_interval = False
                # print 'RECEIVED INTERVAL TIMER SIGNAL'
                if self.show_params['repeat'] == 'repeat':
                    self.wait_for_trigger()
                else:
                    self.stop_timers()
                    self.ending_reason = 'user-stop'
                    Show.base_close_or_unload(self)
            else:
                self.poll_for_interval_timer = self.canvas.after(
                    1000, self.what_next_after_showing)

        # has content of list been changed (replaced if it has, used for content of livelist)
        # causes it to go to wait_for_trigger and start_list
        #not sure why need clos_and_unload here ???????
        elif self.medialist.replace_if_changed() is True:
            self.ending_reason = 'change-medialist'
            # print 'CHANGE REQ'
            Show.base_close_or_unload(self)

        # otherwise consider operation that might show the next track
        else:
            # setup default direction for next track as normally goes forward unless kicked back
            self.kickback_for_next_track = False
            # print 'init direction to False at begin of what_next_after showing', self.kickback_for_next_track
            # end trigger from input, or track count
            if self.end_trigger_signal is True or (self.track_count_limit > 0
                                                   and self.track_count
                                                   == self.track_count_limit):
                self.end_trigger_signal = False
                # repeat so test start trigger
                if self.show_params['repeat'] == 'repeat':
                    self.stop_timers()
                    # print 'END TRIGGER restart'
                    self.wait_for_trigger()
                else:
                    # single run so exit show
                    if self.level != 0:
                        self.kickback_for_next_track = False
                        self.subshow_kickback_signal = False
                        self.end('normal',
                                 "End of single run - Return from Sub Show")
                    else:
                        # end of single run and at top - exit the show
                        self.stop_timers()
                        self.ending_reason = 'user-stop'
                        Show.base_close_or_unload(self)

            # user wants to play child
            elif self.play_child_signal is True:
                self.play_child_signal = False
                index = self.medialist.index_of_track(self.child_track_ref)
                if index >= 0:
                    # don't use select the track as need to preserve mediashow sequence for returning from child
                    child_track = self.medialist.track(index)
                    Show.write_stats(self, 'play child', self.show_params,
                                     child_track)
                    self.display_eggtimer()
                    self.enable_hint = False
                    self.start_load_show_loop(child_track)
                else:
                    self.mon.err(
                        self, "Child not found in medialist: " +
                        self.child_track_ref)
                    self.ending_reason = 'error'
                    Show.base_close_or_unload(self)

            # skip to next track on user input or after subshow
            elif self.next_track_signal is True:
                # print 'skip forward test' ,self.subshow_kickback_signal
                if self.next_track_signal is True or self.subshow_kickback_signal is False:
                    self.next_track_signal = False
                    self.kickback_for_next_track = False
                    if self.medialist.at_end() is True:
                        # medialist_at_end can give false positive for shuffle
                        if self.show_params[
                                'sequence'] == "ordered" and self.show_params[
                                    'repeat'] == 'repeat':
                            self.wait_for_trigger()
                        elif self.show_params[
                                'sequence'] == "ordered" and self.show_params[
                                    'repeat'] == 'single-run':
                            if self.level != 0:
                                self.kickback_for_next_track = False
                                self.subshow_kickback_signal = False
                                # print 'end subshow skip forward test, self. direction is ' ,self.kickback_for_next_track
                                self.end('normal', "Return from Sub Show")
                            else:
                                # end of single run and at top - exit the show
                                self.stop_timers()
                                self.ending_reason = 'user-stop'
                                Show.base_close_or_unload(self)
                        else:
                            # shuffling  - just do next track
                            self.kickback_for_next_track = False
                            self.medialist.next(self.show_params['sequence'])
                            self.start_load_show_loop(
                                self.medialist.selected_track())
                    else:
                        # not at end just do next track
                        self.medialist.next(self.show_params['sequence'])
                        self.start_load_show_loop(
                            self.medialist.selected_track())

            # skip to previous track on user input or after subshow
            elif self.previous_track_signal is True or self.subshow_kickback_signal is True:
                # print 'skip backward test, subshow kickback is' ,self.subshow_kickback_signal
                self.subshow_kickback_signal = False
                self.previous_track_signal = False
                self.kickback_for_next_track = True
                # medialist_at_start can give false positive for shuffle
                if self.medialist.at_start() is True:
                    # print 'AT START'
                    if self.show_params[
                            'sequence'] == "ordered" and self.show_params[
                                'repeat'] == 'repeat':
                        self.kickback_for_next_track = True
                        self.wait_for_trigger()
                    elif self.show_params[
                            'sequence'] == "ordered" and self.show_params[
                                'repeat'] == 'single-run':
                        if self.level != 0:
                            self.kickback_for_next_track = True
                            self.subshow_kickback_signal = True
                            # print 'end subshow skip forward test, self. direction is ' ,self.kickback_for_next_track
                            self.end('normal', "Return from Sub Show")
                        else:
                            # end of single run and at top - exit the show
                            self.stop_timers()
                            self.ending_reason = 'user-stop'
                            Show.base_close_or_unload(self)
                    else:
                        # shuffling  - just do previous track
                        self.kickback_for_next_track = True
                        self.medialist.previous(self.show_params['sequence'])
                        self.start_load_show_loop(
                            self.medialist.selected_track())
                else:
                    # not at end just do next track
                    self.medialist.previous(self.show_params['sequence'])
                    self.start_load_show_loop(self.medialist.selected_track())

            # AT END OF MEDIALIST
            elif self.medialist.at_end() is True:
                # print 'MEDIALIST AT END'

                # interval>0 and list finished so wait for the interval timer
                if self.show_params[
                        'sequence'] == "ordered" and self.interval > 0 and self.interval_timer_signal == False:
                    self.waiting_for_interval = True
                    # print 'WAITING FOR INTERVAL'
                    Show.base_shuffle(self)
                    Show.base_track_ready_callback(self, False)
                    self.poll_for_interval_timer = self.canvas.after(
                        200, self.what_next_after_showing)

                # interval=0
                #elif self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'repeat' and self.show_params['trigger-end-type']== 'interval' and int(self.show_params['trigger-end-param']) == 0:
                #self.medialist.next(self.show_params['sequence'])
                # self.start_load_show_loop(self.medialist.selected_track())

                # shuffling so there is no end condition, get out of end test
                elif self.show_params['sequence'] == "shuffle":
                    self.medialist.next(self.show_params['sequence'])
                    self.start_load_show_loop(self.medialist.selected_track())

                # nothing special to do at end of list, just repeat or exit
                elif self.show_params['sequence'] == "ordered":
                    if self.show_params['repeat'] == 'repeat':
                        self.wait_for_trigger()
                    else:
                        # single run
                        # if not at top return to parent
                        if self.level != 0:
                            self.end('normal', "End of Single Run")
                        else:
                            # at top so close the show
                            self.stop_timers()
                            self.ending_reason = 'user-stop'
                            Show.base_close_or_unload(self)

                else:
                    self.mon.err(
                        self, "Unhandled playing event at end of list: " +
                        self.show_params['sequence'] + ' with ' +
                        self.show_params['repeat'] + " of " +
                        self.show_params['trigger-end-param'])
                    self.end(
                        'error', "Unhandled playing event at end of list: " +
                        self.show_params['sequence'] + ' with ' +
                        self.show_params['repeat'] + " of " +
                        self.show_params['trigger-end-param'])

            elif self.medialist.at_end() is False:
                # nothing special just do the next track
                self.medialist.next(self.show_params['sequence'])
                self.start_load_show_loop(self.medialist.selected_track())

            else:
                # unhandled state
                self.mon.err(
                    self, "Unhandled playing event: " +
                    self.show_params['sequence'] + ' with ' +
                    self.show_params['repeat'] + " of " +
                    self.show_params['trigger-end-param'])
                self.end(
                    'error', "Unhandled playing event: " +
                    self.show_params['sequence'] + ' with ' +
                    self.show_params['repeat'] + " of " +
                    self.show_params['trigger-end-param'])
    def what_next_after_showing(self):
        #inhibit for trigger next
        self.playing_track = False
        # print 'WHAT NEXT'
        self.mon.trace(self, self.pretty_what_next_after_showing_state())

        self.track_count += 1
        # set false when child rack is to be played
        self.enable_hint = True

        # first of all deal with conditions that do not require the next track to be shown
        # some of the conditions can happen at any time, others only when a track is closed or at pause_at_end

        # need to terminate
        if self.terminate_signal is True:
            self.terminate_signal = False
            self.stop_timers()
            # set what to do after closed or unloaded
            self.ending_reason = 'killed'
            Show.base_close_or_unload(self)

        elif self.error_signal == True or self.req_next == 'error':
            self.error_signal = False
            self.req_next = ''
            self.stop_timers()
            # set what to do after closed or unloaded
            self.ending_reason = 'error'
            Show.base_close_or_unload(self)

        # used for exiting show from other shows, time of day, external etc.
        elif self.exit_signal is True:
            self.exit_signal = False
            self.stop_timers()
            self.ending_reason = 'exit'
            Show.base_close_or_unload(self)

        #  show timeout
        elif self.show_timeout_signal is True:
            self.show_timeout_signal = False
            self.stop_timers()
            self.ending_reason = 'user-stop'
            Show.base_close_or_unload(self)

        # user wants to stop the show
        elif self.user_stop_signal is True:
            self.user_stop_signal = False
            # print 'user stop'
            self.stop_timers()
            self.ending_reason = 'user-stop'
            Show.base_close_or_unload(self)

    # interval > 0. If last track has finished we are waiting for interval timer before ending the list
    # note: if medialist finishes after interval is up then this route is used to start trigger.
        elif self.waiting_for_interval is True:
            # interval_timer_signal set by alarm clock started in start_list
            if self.interval_timer_signal is True:
                self.interval_timer_signal = False
                self.waiting_for_interval = False
                # print 'RECEIVED INTERVAL TIMER SIGNAL'
                if self.show_params['repeat'] == 'repeat':
                    self.wait_for_trigger()
                else:
                    self.stop_timers()
                    self.ending_reason = 'user-stop'
                    Show.base_close_or_unload(self)
            else:
                self.poll_for_interval_timer = self.canvas.after(
                    1000, self.what_next_after_showing)

        else:
            self.medialist.create_new_livelist()
            escapetrack_required = self.escapetrack_required
            self.escapetrack_required = False
            # print escapetrack_required,self.medialist.new_length()
            if escapetrack_required is True and self.medialist.new_length(
            ) == 0:
                # print 'use escape track'
                index = self.medialist.index_of_track(
                    self.show_params['escape-track-ref'])
                self.mon.log(
                    self, 'Starting Escape Track: ' +
                    self.show_params['escape-track-ref'])
                if index >= 0:
                    # don't use select the track as need to preserve mediashow sequence for returning from esacpe track
                    escape_track = self.medialist.track(index)
                    Show.write_stats(self, 'play escape track',
                                     self.show_params, escape_track)
                    self.display_eggtimer()
                    # use new empty livelist so if changed works OK when return from empty track
                    self.medialist.use_new_livelist()
                    self.start_load_show_loop(escape_track)
                else:
                    self.mon.err(self, "Escape Track empty")
                    self.end('error', "Escape Track empty")

            # print 'FOR IF CHANGED',self.first_list,self.medialist.length(),self.medialist.new_length(),self.medialist.livelist_changed()
            elif self.first_list is True or self.medialist.livelist_changed(
            ) is True or (self.medialist.length() == 0
                          and self.medialist.new_length() == 0):

                if self.first_list is False:
                    # do show control
                    if self.medialist.length(
                    ) == 0 and self.medialist.new_length() != 0:
                        # print 'show control empty to not empty'
                        # do show control when goes from not empty to empty only
                        self.show_control(
                            self.show_params['show-control-not-empty'])

                    elif self.medialist.length(
                    ) != 0 and self.medialist.new_length() == 0:
                        # print 'show control not empty to empty'
                        # do show control when goes from empty to not empty only
                        self.show_control(
                            self.show_params['show-control-empty'])

                self.first_list = False

                if self.medialist.new_length(
                ) == 0 and self.show_params['repeat'] == 'repeat':
                    # start empty track/show
                    index = self.medialist.index_of_track(
                        self.show_params['empty-track-ref'])
                    self.mon.log(
                        self, 'Starting Empty Track: ' +
                        self.show_params['empty-track-ref'])
                    if index >= 0:
                        # don't use select the track as need to preserve mediashow sequence for returning from empty track/show
                        empty_track = self.medialist.track(index)
                        # print 'play empty track', empty_track['title'],empty_track['type']
                        Show.write_stats(self, 'play empty track',
                                         self.show_params, empty_track)
                        if empty_track['type'] == 'show':
                            self.escapetrack_required = True

                        self.display_eggtimer()
                        # use new empty livelist so if changed works OK when return from empty track
                        self.medialist.use_new_livelist()
                        self.start_load_show_loop(empty_track)
                    else:
                        self.mon.err(self, "List Empty Track not specified")
                        self.end('error', "List Empty Track not specified")

                elif self.medialist.new_length(
                ) == 0 and self.show_params['repeat'] == 'single-run':
                    if self.level != 0:
                        self.kickback_for_next_track = False
                        self.subshow_kickback_signal = False
                        self.end('normal',
                                 "End of single run - Return from Sub Show")
                    else:
                        # end of single run and at top - exit the show
                        self.stop_timers()
                        self.ending_reason = 'user-stop'
                        Show.base_close_or_unload(self)

                else:
                    #changed but new is not zero
                    self.medialist.use_new_livelist()
                    # print 'livelist changed and not empty'
                    self.start_list()

            # otherwise consider operation that might show the next track
            else:
                # print 'ELSE',self.medialist.at_end()
                # report error if medilaist is empty (liveshow will not get this far
                if self.medialist.length() == 0:
                    self.mon.err(self, "Medialist empty")
                    self.end('error', "Medialist empty")

                # setup default direction for next track as normally goes forward unless kicked back
                self.kickback_for_next_track = False
                # print 'init direction to False at begin of what_next_after showing', self.kickback_for_next_track
                # end trigger from input, or track count
                if self.end_trigger_signal is True or (
                        self.track_count_limit > 0
                        and self.track_count == self.track_count_limit):
                    self.end_trigger_signal = False
                    # repeat so test start trigger
                    if self.show_params['repeat'] == 'repeat':
                        self.stop_timers()
                        # print 'END TRIGGER restart'
                        self.wait_for_trigger()
                    else:
                        # single run so exit show
                        if self.level != 0:
                            self.kickback_for_next_track = False
                            self.subshow_kickback_signal = False
                            # print 'single run exit subshow'
                            self.end(
                                'normal',
                                "End of single run - Return from Sub Show")
                        else:
                            # end of single run and at top - exit the show
                            self.stop_timers()
                            # print 'ENDING'
                            self.ending_reason = 'user-stop'
                            Show.base_close_or_unload(self)

                # user wants to play child
                elif self.play_child_signal is True:
                    self.play_child_signal = False
                    index = self.medialist.index_of_track(self.child_track_ref)
                    if index >= 0:
                        # don't use select the track as need to preserve mediashow sequence for returning from child
                        child_track = self.medialist.track(index)
                        Show.write_stats(self, 'play child', self.show_params,
                                         child_track)
                        self.display_eggtimer()
                        self.enable_hint = False
                        self.start_load_show_loop(child_track)
                    else:
                        self.mon.err(
                            self, "Child not found in medialist: " +
                            self.child_track_ref)
                        self.ending_reason = 'error'
                        Show.base_close_or_unload(self)

                elif self.repeat_track_signal is True:
                    self.repeat_track_signal = False
                    self.start_load_show_loop(self.medialist.selected_track())

                # skip to next track on user input or after subshow
                elif self.next_track_signal is True:
                    # print 'skip forward test' ,self.subshow_kickback_signal
                    if self.next_track_signal is True or self.subshow_kickback_signal is False:
                        self.next_track_signal = False
                        self.kickback_for_next_track = False
                        if self.medialist.at_end() is True:
                            # medialist_at_end can give false positive for shuffle
                            if self.show_params[
                                    'sequence'] == "ordered" and self.show_params[
                                        'repeat'] == 'repeat':
                                self.wait_for_trigger()
                            elif self.show_params[
                                    'sequence'] == "ordered" and self.show_params[
                                        'repeat'] == 'single-run':
                                if self.level != 0:
                                    self.kickback_for_next_track = False
                                    self.subshow_kickback_signal = False
                                    # print 'end subshow skip forward test, self. direction is ' ,self.kickback_for_next_track
                                    self.end('normal', "Return from Sub Show")
                                else:
                                    # end of single run and at top - exit the show
                                    self.stop_timers()
                                    self.ending_reason = 'user-stop'
                                    Show.base_close_or_unload(self)
                            else:
                                # shuffling  - just do next track
                                self.kickback_for_next_track = False
                                self.medialist.next(
                                    self.show_params['sequence'])
                                self.start_load_show_loop(
                                    self.medialist.selected_track())
                        else:
                            # not at end just do next track
                            self.medialist.next(self.show_params['sequence'])
                            self.start_load_show_loop(
                                self.medialist.selected_track())

                # skip to previous track on user input or after subshow
                elif self.previous_track_signal is True or self.subshow_kickback_signal is True:
                    # print 'skip backward test, subshow kickback is' ,self.subshow_kickback_signal
                    self.subshow_kickback_signal = False
                    self.previous_track_signal = False
                    self.kickback_for_next_track = True
                    # medialist_at_start can give false positive for shuffle
                    if self.medialist.at_start() is True:
                        # print 'AT START'
                        if self.show_params[
                                'sequence'] == "ordered" and self.show_params[
                                    'repeat'] == 'repeat':
                            self.kickback_for_next_track = True
                            self.wait_for_trigger()
                        elif self.show_params[
                                'sequence'] == "ordered" and self.show_params[
                                    'repeat'] == 'single-run':
                            if self.level != 0:
                                self.kickback_for_next_track = True
                                self.subshow_kickback_signal = True
                                # print 'end subshow skip forward test, self. direction is ' ,self.kickback_for_next_track
                                self.end('normal', "Return from Sub Show")
                            else:
                                # end of single run and at top - exit the show
                                self.stop_timers()
                                self.ending_reason = 'user-stop'
                                Show.base_close_or_unload(self)
                        else:
                            # shuffling  - just do previous track
                            self.kickback_for_next_track = True
                            self.medialist.previous(
                                self.show_params['sequence'])
                            self.start_load_show_loop(
                                self.medialist.selected_track())
                    else:
                        # not at end just do next track
                        self.medialist.previous(self.show_params['sequence'])
                        self.start_load_show_loop(
                            self.medialist.selected_track())

                # AT END OF MEDIALIST
                elif self.medialist.at_end() is True:
                    # print 'MEDIALIST AT END'

                    # interval>0 and list finished so wait for the interval timer
                    if self.show_params[
                            'sequence'] == "ordered" and self.interval > 0 and self.interval_timer_signal == False:
                        self.waiting_for_interval = True
                        # print 'WAITING FOR INTERVAL'
                        Show.base_shuffle(self)
                        Show.base_track_ready_callback(self, False)
                        self.poll_for_interval_timer = self.canvas.after(
                            200, self.what_next_after_showing)

                    # interval=0
                    #elif self.show_params['sequence'] == "ordered" and self.show_params['repeat'] == 'repeat' and self.show_params['trigger-end-type']== 'interval' and int(self.show_params['trigger-end-param']) == 0:
                    #self.medialist.next(self.show_params['sequence'])
                    # self.start_load_show_loop(self.medialist.selected_track())

                    # shuffling so there is no end condition, get out of end test
                    elif self.show_params['sequence'] == "shuffle":
                        self.medialist.next(self.show_params['sequence'])
                        self.start_load_show_loop(
                            self.medialist.selected_track())

                    # nothing special to do at end of list, just repeat or exit
                    elif self.show_params['sequence'] == "ordered":
                        if self.show_params['repeat'] == 'repeat':
                            # print 'repeating at end of list'
                            self.wait_for_trigger()
                        else:
                            # single run
                            # if not at top return to parent
                            if self.level != 0:
                                self.end('normal', "End of Single Run")
                            else:
                                # at top so close the show
                                # print 'closing show'
                                self.stop_timers()
                                self.ending_reason = 'user-stop'
                                Show.base_close_or_unload(self)

                    else:
                        self.mon.err(
                            self, "Unhandled playing event at end of list: " +
                            self.show_params['sequence'] + ' with ' +
                            self.show_params['repeat'] + " of " +
                            self.show_params['trigger-end-param'])
                        self.end(
                            'error',
                            "Unhandled playing event at end of list: " +
                            self.show_params['sequence'] + ' with ' +
                            self.show_params['repeat'] + " of " +
                            self.show_params['trigger-end-param'])

                elif self.medialist.at_end() is False:
                    # nothing special just do the next track
                    # print 'nothing special'
                    if self.wait_for_next_trigger is False:
                        self.medialist.next(self.show_params['sequence'])
                        self.start_load_show_loop(
                            self.medialist.selected_track())
                    else:
                        #close the previous track to display admin message
                        Show.base_shuffle(self)
                        Show.base_track_ready_callback(self, False)
                        Show.display_admin_message(
                            self, self.show_params['trigger-wait-text'])

                else:
                    # unhandled state
                    self.mon.err(
                        self, "Unhandled playing event: " +
                        self.show_params['sequence'] + ' with ' +
                        self.show_params['repeat'] + " of " +
                        self.show_params['trigger-end-param'])
                    self.end(
                        'error', "Unhandled playing event: " +
                        self.show_params['sequence'] + ' with ' +
                        self.show_params['repeat'] + " of " +
                        self.show_params['trigger-end-param'])
示例#10
0
    def what_next_after_showing(self):
        self.mon.trace(self, '')
        # 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.continue_timeout = False

            # home
            if self.next_track_op in ('home'):
                # back to 1 before home
                back_ref = self.path.back_to(self.home_track_ref)
                if back_ref == '':
                    self.mon.err(
                        self, "home - home track not in path: " +
                        self.home_track_ref)
                    self.end(
                        'error', "home - home track not in path: " +
                        self.home_track_ref)
                # play home
                self.next_track_ref = self.home_track_ref
                self.path.append(self.next_track_ref)
                if self.debug: print 'Executed Home ' + self.path.pretty_path()

            # return-by
            elif self.next_track_op in ('return-by'):
                if self.current_track_ref != self.home_track_ref:
                    # back n stopping at home
                    # back one more and return it
                    back_ref = self.path.back_by(self.home_track_ref,
                                                 self.next_track_arg)
                    # use returned track
                    self.next_track_ref = back_ref
                    self.path.append(self.next_track_ref)
                    if self.debug:
                        print 'Executed Return By' + self.next_track_arg + self.path.pretty_path(
                        )

            # repeat is return by 1
            elif self.next_track_op in ('repeat'):
                # print 'current', self.current_track_ref
                # print 'home', self.home_track_ref
                self.path.pop_for_sibling()
                self.next_track_ref = self.current_track_ref
                self.path.append(self.current_track_ref)
                self.continue_timeout = True
                if self.debug:
                    print 'Executed Repeat ' + self.path.pretty_path()

            # return-to
            elif self.next_track_op in ('return-to'):
                # back to one before return-to track
                back_ref = self.path.back_to(self.next_track_arg)
                if back_ref == '':
                    self.mon.err(
                        self, "return-to - track not in path: " +
                        self.next_track_arg)
                    self.end(
                        'error', "return-to - track not in path: " +
                        self.next_track_arg)
                # and append the return to track
                self.next_track_ref = self.next_track_arg
                self.path.append(self.next_track_ref)
                if self.debug:
                    print 'Executed Return To' + self.next_track_arg + self.path.pretty_path(
                    )

            # call
            elif self.next_track_op in ('call'):
                # append the required track
                self.path.append(self.next_track_arg)
                self.next_track_ref = self.next_track_arg
                if self.debug:
                    print 'Executed Call ' + self.next_track_arg + self.path.pretty_path(
                    )

            # goto
            elif self.next_track_op in ('goto'):
                self.path.empty()
                # add the goto track
                self.next_track_ref = self.next_track_arg
                self.path.append(self.next_track_arg)
                if self.debug:
                    print 'Executed Goto ' + self.next_track_arg + self.path.pretty_path(
                    )

            # jump
            elif self.next_track_op in ('jump'):
                # back to home and remove it
                back_ref = self.path.back_to(self.home_track_ref)
                if back_ref == '':
                    self.mon.err(
                        self, "jump - home track not in path: " +
                        self.home_track_ref)
                    self.end(
                        'error',
                        "jump - track not in path: " + self.home_track_ref)
                # add back the home track without playing it
                self.path.append(self.home_track_ref)
                # append the jumped to track
                self.next_track_ref = self.next_track_arg
                self.path.append(self.next_track_ref)
                if self.debug:
                    print 'Executed Jump ' + self.next_track_arg + self.path.pretty_path(
                    )

            else:
                self.mon.err(
                    self, "unaddressed what next: " + self.next_track_op +
                    ' ' + self.next_track_arg)
                self.end(
                    'error', "unaddressed what next: " + self.next_track_op +
                    ' ' + self.next_track_arg)

            self.current_track_ref = self.next_track_ref
            index = self.medialist.index_of_track(self.next_track_ref)
            if index >= 0:
                Show.write_stats(self, self.next_track_op, self.show_params,
                                 self.medialist.track(index))
                # don't use select the track as not using selected_track in hyperlinkshow
                self.start_load_show_loop(self.medialist.track(index))

            else:
                self.mon.err(
                    self, "next-track not found in medialist: " +
                    self.next_track_ref)
                self.end(
                    'error', "next track not found in medialist: " +
                    self.next_track_ref)

        else:
            # track ends naturally look to see if there is a pp-onend link
            found, link_op, link_arg = self.path.find_link(
                'pp-onend', self.links)
            if found is True:
                if link_op == 'exit':
                    self.user_stop_signal = True
                    self.current_player.input_pressed('stop')
                    self.what_next_after_showing()
                elif link_op == 'home':
                    self.decode_home()
                    self.what_next_after_showing()
                elif link_op == 'return':
                    self.decode_return(link_arg)
                    self.what_next_after_showing()
                elif link_op == 'call':
                    self.decode_call(link_arg)
                    self.what_next_after_showing()
                elif link_op == 'goto':
                    self.decode_goto(link_arg)
                    self.what_next_after_showing()
                elif link_op == 'jump':
                    self.decode_jump(link_arg)
                    self.what_next_after_showing()
                elif link_op == 'repeat':
                    self.decode_repeat()
                    self.what_next_after_showing()
                else:
                    self.mon.err(
                        self, "unknown link command for pp_onend: " + link_op)
                    self.end('error',
                             "unkown link command for pp-onend: " + link_op)
            else:
                if self.show_params['disable-controls'] != 'yes':
                    self.mon.err(
                        self, "pp-onend for this track not found: " + link_op)
                    self.end('error',
                             "pp-onend for this track not found: " + link_op)