def __init__(self, canvas, cd, track_params ): """ canvas - the canvas onto which the video is to be drawn (not!!) cd - configuration dictionary track_params - config dictionary for this track overides cd """ self.mon=Monitor() self.mon.on() #instantiate arguments self.cd=cd #configuration dictionary for the videoplayer self.canvas = canvas #canvas onto which video should be played but isn't! Use as widget for alarm self.track_params=track_params # get config from medialist if there. if 'omx-audio' in self.track_params and self.track_params['omx-audio']<>"": self.omx_audio= self.track_params['omx-audio'] else: self.omx_audio= self.cd['omx-audio'] if self.omx_audio<>"": self.omx_audio= "-o "+ self.omx_audio # could put instance generation in play, not sure which is better. self.omx=OMXDriver() self._tick_timer=None self.error=False self.terminate_required=False self._init_play_state_machine()
def play_video(self): if (self.image_timer): self.main.after_cancel(self.image_timer) # remove image from canvas if exists if (self.annot): self.canvas.delete(self.annot) if (self.img): self.canvas.itemconfig(self.image_on_canvas, image='') if (self.rect): self.canvas.delete(self.rect) if self.verbose: print ("playing video "+self.current_track['location'], flush=True) # set subtitle options subop="" if (self.current_track['omx-subtitles'] != ''): subop = "--subtitles \""+self.complete_path(self.current_track['omx-subtitles'])+"\" " subop += "--lines "+self.current_track['omx-subtitles-numlines']+" --font-size 40 " # kill off any zombie omxplayers subprocess.call("killall omxplayer omxplayer.bin", shell=True) self.omx = OMXDriver(self.verbose) self.omx.play(self.complete_path(self.current_track['location']), subop) self.check_video_loop()
def load(self, track, loaded_callback, enable_menu): # instantiate arguments self.track = track self.loaded_callback = loaded_callback #callback when loaded # print '!!!!!!!!!!! videoplayer load',self.track self.mon.log( self, "Load track received from show Id: " + str(self.show_id) + ' ' + self.track) self.mon.trace(self, '') # do common bits of load Player.pre_load(self) # set up video window status, message, command, has_window, x1, y1, x2, y2 = self.parse_video_window( self.omx_window) if status == 'error': self.mon.err( self, 'omx window error: ' + message + ' in ' + self.omx_window) self.play_state = 'load-failed' if self.loaded_callback is not None: self.loaded_callback('error', message) return else: if has_window is True: self.omx_window_processed = '--win " ' + str(x1) + ' ' + str( y1) + ' ' + str(x2) + ' ' + str(y2) + ' " ' else: self.omx_window_processed = '' # 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 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') return self.omx = OMXDriver(self.canvas, self.pp_dir) self.start_state_machine_load(self.track)
def load(self, track, loaded_callback, enable_menu): # instantiate arguments self.track = track self.loaded_callback = loaded_callback #callback when loaded # print '!!!!!!!!!!! videoplayer load',self.track self.mon.log( self, "Load track received from show Id: " + str(self.show_id) + ' ' + self.track) self.mon.trace(self, '') # do common bits of load Player.pre_load(self) # set up video display if self.track_params['display-name'] != "": video_display_name = self.track_params['display-name'] else: video_display_name = self.show_canvas_display_name status, message, self.omx_display_id = self.dm.id_of_display( video_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', 'Display not connected: ' + video_display_name) return # set up video window and calc orientation status, message, command, has_window, x1, y1, x2, y2 = self.parse_video_window( self.omx_window, self.omx_display_id) if status == 'error': self.mon.err( self, 'omx window error: ' + message + ' in ' + self.omx_window) self.play_state = 'load-failed' if self.loaded_callback is not None: self.loaded_callback( 'error', 'omx window error: ' + message + ' in ' + self.omx_window) return else: if has_window is True: self.omx_window_processed = '--win " ' + str(x1) + ' ' + str( y1) + ' ' + str(x2) + ' ' + str(y2) + ' " ' else: self.omx_window_processed = self.omx_aspect_mode # 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 not (track[0:3] in ('udp', 'tcp') or track[0:4] in ('rtsp', 'rtmp')): if 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 self.omx = OMXDriver(self.canvas, self.pp_dir) self.start_state_machine_load(self.track)
def __init__(self, show_id, root, canvas, show_params, track_params , pp_dir, pp_home, pp_profile): self.mon=Monitor() self.mon.on() #instantiate arguments self.show_id=show_id self.root=root self.canvas = canvas self.show_params=show_params self.track_params=track_params self.pp_dir=pp_dir self.pp_home=pp_home self.pp_profile=pp_profile # get config from medialist if there. if self.track_params['omx-audio']<>"": self.omx_audio= self.track_params['omx-audio'] else: self.omx_audio= self.show_params['omx-audio'] if self.omx_audio<>"": self.omx_audio= "-o "+ self.omx_audio if self.track_params['omx-volume']<>"": self.omx_volume= self.track_params['omx-volume'] else: self.omx_volume= self.show_params['omx-volume'] if self.omx_volume<>"": self.omx_volume= "--vol "+ str(int(self.omx_volume)*100) + ' ' if self.track_params['omx-window']<>'': self.omx_window= self.track_params['omx-window'] else: self.omx_window= self.show_params['omx-window'] # get background image from profile. self.background_file='' if self.track_params['background-image']<>"": self.background_file= self.track_params['background-image'] else: if self.track_params['display-show-background']=='yes': self.background_file= self.show_params['background-image'] # get background colour from profile. if self.track_params['background-colour']<>"": self.background_colour= self.track_params['background-colour'] else: self.background_colour= self.show_params['background-colour'] self.centre_x = int(self.canvas['width'])/2 self.centre_y = int(self.canvas['height'])/2 #get animation instructions from profile self.animate_begin_text=self.track_params['animate-begin'] self.animate_end_text=self.track_params['animate-end'] # open the plugin Manager self.pim=PluginManager(self.show_id,self.root,self.canvas,self.show_params,self.track_params,self.pp_dir,self.pp_home,self.pp_profile) #create an instance of PPIO so we can create gpio events self.ppio = PPIO() # could put instance generation in play, not sure which is better. self.omx=OMXDriver(self.canvas) self.tick_timer=None self.init_play_state_machine()