예제 #1
0
    def load(self, text, loaded_callback, enable_menu):
        # instantiate arguments
        self.track = text
        self.loaded_callback = loaded_callback  # callback when loaded
        self.mon.trace(self, '')

        # do common bits of  load
        Player.pre_load(self)

        # parse the duration
        status, message, self.duration = Player.parse_duration(
            self.duration_text)
        if status == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            self.loaded_callback('error', message)
            return

        # load the plugin, this may modify self.track and enable the plugin drawing to canvas
        if self.track_params['plugin'] != '':
            status, message = self.load_plugin()
            # can modify self.track with new text, does not touch message location
            if status == 'error':
                self.mon.err(self, message)
                self.play_state = 'load-failed'
                if self.loaded_callback is not None:
                    self.loaded_callback('error', message)
                    return

        # load the images and text including message text
        status, message = self.load_x_content(enable_menu)
        if status == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return
        else:
            self.play_state = 'loaded'
            if self.loaded_callback is not None:
                self.loaded_callback('loaded', 'message track loaded')
예제 #2
0
    def load(self,track,loaded_callback,enable_menu):
        # instantiate arguments
        self.track=track
        self.loaded_callback=loaded_callback   #callback when loaded

        self.mon.trace(self,'')
        
        #for pulse get sink name and check device is connected 
        self.audio_sys=self.am.get_audio_sys()
        if self.audio_sys == 'pulse':
            status,message,self.mplayer_sink = self.am.get_sink(self.mplayer_audio)
            if status == 'error':
                self.mon.err(self,message)
                self.play_state='load-failed'
                if self.loaded_callback is not  None:
                    self.loaded_callback('error',message)
                    return
                    
            if not self.am.sink_connected(self.mplayer_sink):
                self.mon.err(self,'audio device not connected - '+self.mplayer_audio + '/n sink: '+self.mplayer_sink)
                self.play_state='load-failed'
                if self.loaded_callback is not  None:
                    self.loaded_callback('error','audio device not connected')
                    return            

        # do common bits of  load
        Player.pre_load(self)
        
        # load the plugin, this may modify self.track and enable the plugin drawign to canvas
        if self.track_params['plugin'] != '':
            status,message=self.load_plugin()
            if status == 'error':
                self.mon.err(self,message)
                self.play_state='load-failed'
                if self.loaded_callback is not  None:
                    self.loaded_callback('error',message)
                    return

        # load the images and text
        status,message=self.load_x_content(enable_menu)
        if status == 'error':
            self.mon.err(self,message)
            self.play_state='load-failed'
            if self.loaded_callback is not  None:
                self.loaded_callback('error',message)
                return

        if self.duration_text != '':
            status,message,duration100=Player.parse_duration(self.duration_text)
            if status =='error':
                self.mon.err(self,message)
                self.play_state='load-failed'
                if self.loaded_callback is not  None:
                    self.loaded_callback('error','track file not found: ' + track)
                    return
            self.duration_limit= 2* duration100
        else:
            self.duration_limit=-1
        #print (self.duration_limit)


        if track !='' and self.duration_limit!=0 and not os.path.exists(track):
            self.mon.err(self,"Track file not found: "+ track)
            self.play_state='load-failed'
            if self.loaded_callback is not  None:
                self.loaded_callback('error','track file not found: ' + track)
                return

        # just create instance of mplayer don't bother with any pre-load
        self.mplayer=MplayerDriver(self.canvas,self.pp_dir)
        self.play_state='loaded'
        self.mon.log(self,"<Track loaded from show Id: "+ str(self.show_id))
        if self.loaded_callback is not None:
            self.loaded_callback('loaded','audio track loaded')
예제 #3
0
    def load(self, track, loaded_callback, enable_menu):
        # instantiate arguments
        self.loaded_callback = loaded_callback  # callback when loaded
        self.mon.trace(self, '')

        status, message, duration100 = Player.parse_duration(
            self.duration_text)
        if status == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return
        self.duration = 2 * duration100

        # Is display valid and connected
        status, message, self.display_id = self.dm.id_of_display(
            self.show_canvas_display_name)
        if status == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', 'cannot find file; ' + track)
                return

        # does media exist
        if not ':' in track:
            if not os.path.exists(track):
                self.mon.err(self, 'cannot find file; ' + track)
                self.play_state = 'load-failed'
                if self.loaded_callback is not None:
                    self.loaded_callback('error', 'cannot find file; ' + track)
                    return

        # add file:// to files.
        if ':' in track:
            self.current_url = track
        else:
            self.current_url = 'file://' + track
        # do common bits of  load
        Player.pre_load(self)

        # prepare chromium options
        status, message = self.process_chrome_options()
        if status == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return

        # parse browser commands to self.command_list
        reason, message = self.parse_commands(
            self.track_params['browser-commands'])
        if reason == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return

        # load the plugin, this may modify self.track and enable the plugin drawing to canvas
        if self.track_params['plugin'] != '':
            status, message = self.load_plugin()
            if status == 'error':
                self.mon.err(self, message)
                self.play_state = 'load-failed'
                if self.loaded_callback is not None:
                    self.loaded_callback('error', message)
                    return

        # start loading the browser
        self.play_state = 'loading'

        # load the images and text
        status, message = self.load_x_content(enable_menu)
        if status == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return

        #start the browser
        self.driver_open()

        # for kiosk and fullscreen need to get the url - in browser command for app mode
        if self.app_mode is False:
            self.driver_get(self.current_url)
        self.mon.log(self,
                     'Loading browser from show Id: ' + str(self.show_id))

        self.play_state = 'loaded'

        # and start executing the browser commands
        self.play_commands()
        self.mon.log(self, "      State machine: chromium loaded")
        if self.loaded_callback is not None:
            self.loaded_callback('normal', 'browser loaded')
        return
예제 #4
0
    def load(self, track, loaded_callback, enable_menu):
        # instantiate arguments
        self.track = track
        self.loaded_callback = loaded_callback  # callback when loaded
        self.mon.trace(self, '')

        # do common bits of  load
        Player.pre_load(self)

        #parse web window
        reason, message, command, has_window, x1, y1, x2, y2 = self.parse_window(
            self.web_window)
        if reason == 'error':
            self.mon.err(
                self, 'web window error: ' + '  ' + message + ' in ' +
                self.web_window)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return

        status, message, duration100 = Player.parse_duration(
            self.duration_text)
        if status == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return
        self.duration = 2 * duration100

        # compute web_window size
        if has_window is False:
            self.geometry = ' --geometry=maximized '
        else:
            width = x2 - x1
            height = y2 - y1
            self.geometry = "--geometry=%dx%d%+d%+d " % (width, height, x1, y1)

        # parse browser commands to self.command_list
        reason, message = self.parse_commands(
            self.track_params['browser-commands'])
        if reason == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return

        # load the plugin, this may modify self.track and enable the plugin drawing to canvas
        if self.track_params['plugin'] != '':
            status, message = self.load_plugin()
            if status == 'error':
                self.mon.err(self, message)
                self.play_state = 'load-failed'
                if self.loaded_callback is not None:
                    self.loaded_callback('error', message)
                    return

        # start loading the browser
        self.play_state = 'loading'
        self.bplayer.play(self.track, self.geometry)
        self.mon.log(self,
                     'Loading browser from show Id: ' + str(self.show_id))

        # load the images and text
        status, message = self.load_x_content(enable_menu)
        if status == 'error':
            self.mon.err(self, message)
            self.play_state = 'load-failed'
            if self.loaded_callback is not None:
                self.loaded_callback('error', message)
                return

        # wait for browser to load
        self.start_load_state_machine()