def __init__(self, playlist, videofolder, omxargs, omxpath, cleanloop): """Player setup Grabs durations for playlist contents, loads players, starts playback Keyword arguments: playlist -- List of files to play in order videofolder -- Root folder for video file relative paths omxargs -- List of arguments to supply to OMXPlayer (filename will be added) """ self._omxpath = omxpath self._omxargs = omxargs self._videofolder = videofolder self._cleanloop = cleanloop # Get durations for everything in the playlist logging.info("Getting playlist item durations...") for item in playlist: duration = pivtfilelist.get_omx_duration(self.fullpath(item)) if duration > 0: self._playlist.append([item, duration]) if len(self._playlist) < 1: logging.error( "Unable to read the stopvideo or any playlist items. Shutting down" ) raise Exception try: if self._cleanloop == True and len(self._playlist) == 1: self._stopvideo = self._load_internal(self._playlist[0][0], self._playlist[0][1], [ '--loop', ]) self._playing = self._stopvideo else: # Load the main and second videos self._playing = self._load_internal(self._playlist[0][0], self._playlist[0][1]) self._advance_playlist() self._stopvideo = self._load_internal( self._playlist[self._index][0], self._playlist[self._index][1]) self._advance_playlist() if self._playing == None or self._stopvideo == None: logging.error( "Failed to load the first two videos. Shutting down") raise Exception # Launch off the current video self._playing.play() self._nextvideo = self._stopvideo except: logging.exception("Startup failed! This is definitely not good!") raise Exception
def load(self, filename, duration=None): """Load a video file in the background for playback next""" # Grab a duration if needed if duration == None: duration = pivtfilelist.get_omx_duration(self.fullpath(filename)) if duration == 0: return "File could not be opened" if self._loader != None: if (safekill(self._loader) == False): return "Failed to shut down existing" # Is there another video playing now? Do we need to hide this one? if self._playing != None: hvideo = True else: hvideo = False self._loader = self._load_internal(filename, duration, hidevideo=hvideo) if self._loader != None: timeout = 500 while (self._loader.get_ready() == False): if (timeout > 0): timeout -= 1 else: return "Loading timed out" sleep(0.01) logging.info("Loaded %s", filename) return 0 else: return "Loading failed"
def __init__(self, playlist, videofolder, omxargs, omxpath, cleanloop): """Player setup Grabs durations for playlist contents, loads players, starts playback Keyword arguments: playlist -- List of files to play in order videofolder -- Root folder for video file relative paths omxargs -- List of arguments to supply to OMXPlayer (filename will be added) """ self._omxpath = omxpath self._omxargs = omxargs self._videofolder = videofolder self._cleanloop = cleanloop # Get durations for everything in the playlist logging.info("Getting playlist item durations...") for item in playlist: duration = pivtfilelist.get_omx_duration(self.fullpath(item)) if duration > 0: self._playlist.append([item, duration]) if len(self._playlist) < 1: logging.error("Unable to read the stopvideo or any playlist items. Shutting down") raise Exception try: if self._cleanloop == True and len(self._playlist) == 1: self._stopvideo = self._load_internal(self._playlist[0][0], self._playlist[0][1], ['--loop',]) self._playing = self._stopvideo else: # Load the main and second videos self._playing = self._load_internal(self._playlist[0][0], self._playlist[0][1]) self._advance_playlist() self._stopvideo = self._load_internal(self._playlist[self._index][0], self._playlist[self._index][1]) self._advance_playlist() if self._playing == None or self._stopvideo == None: logging.error("Failed to load the first two videos. Shutting down") raise Exception # Launch off the current video self._playing.play() self._nextvideo = self._stopvideo except: logging.exception("Startup failed! This is definitely not good!") raise Exception
def load(self, filename, duration=None): """Load a video file in the background for playback next""" # Grab a duration if needed if duration == None: duration = pivtfilelist.get_omx_duration(self.fullpath(filename)) if duration == 0: return "File could not be opened" if self._loader != None: self._loader.stop() self._loader = self._load_internal(filename, duration) if self._loader != None: if self.automode == True: self._nextvideo = self._loader return 0 else: return "Loading failed"