Merge branch 'Lyptik-master'
This commit is contained in:
commit
76e3e360be
@ -27,13 +27,15 @@ class OMXPlayer(object):
|
|||||||
"""Return list of supported file extensions."""
|
"""Return list of supported file extensions."""
|
||||||
return self._extensions
|
return self._extensions
|
||||||
|
|
||||||
def play(self, movie, loop=False):
|
def play(self, movie, loop=False, vol=0):
|
||||||
"""Play the provided movied file, optionally looping it repeatedly."""
|
"""Play the provided movied file, optionally looping it repeatedly."""
|
||||||
self.stop(3) # Up to 3 second delay to let the old player stop.
|
self.stop(3) # Up to 3 second delay to let the old player stop.
|
||||||
# Assemble list of arguments.
|
# Assemble list of arguments.
|
||||||
args = ['omxplayer']
|
args = ['omxplayer']
|
||||||
args.extend(['-o', self._sound]) # Add sound arguments.
|
args.extend(['-o', self._sound]) # Add sound arguments.
|
||||||
args.extend(self._extra_args) # Add extra arguments from config.
|
args.extend(self._extra_args) # Add extra arguments from config.
|
||||||
|
if vol is not 0:
|
||||||
|
args.extend(['--vol', str(vol)])
|
||||||
if loop:
|
if loop:
|
||||||
args.append('--loop') # Add loop parameter if necessary.
|
args.append('--loop') # Add loop parameter if necessary.
|
||||||
args.append(movie) # Add movie file path.
|
args.append(movie) # Add movie file path.
|
||||||
|
@ -61,6 +61,10 @@ class VideoLooper(object):
|
|||||||
self._fgcolor = map(int, self._config.get('video_looper', 'fgcolor') \
|
self._fgcolor = map(int, self._config.get('video_looper', 'fgcolor') \
|
||||||
.translate(None, ',') \
|
.translate(None, ',') \
|
||||||
.split())
|
.split())
|
||||||
|
# Load sound volume file name value
|
||||||
|
self._sound_vol_file = self._config.get('omxplayer', 'sound_vol_file');
|
||||||
|
# default value to 0 millibels (omxplayer)
|
||||||
|
self._sound_vol = 0
|
||||||
# Initialize pygame and display a blank screen.
|
# Initialize pygame and display a blank screen.
|
||||||
pygame.display.init()
|
pygame.display.init()
|
||||||
pygame.font.init()
|
pygame.font.init()
|
||||||
@ -91,6 +95,13 @@ class VideoLooper(object):
|
|||||||
return importlib.import_module('.' + module, 'Adafruit_Video_Looper') \
|
return importlib.import_module('.' + module, 'Adafruit_Video_Looper') \
|
||||||
.create_file_reader(self._config)
|
.create_file_reader(self._config)
|
||||||
|
|
||||||
|
def _is_number(iself, s):
|
||||||
|
try:
|
||||||
|
float(s)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
def _build_playlist(self):
|
def _build_playlist(self):
|
||||||
"""Search all the file reader paths for movie files with the provided
|
"""Search all the file reader paths for movie files with the provided
|
||||||
extensions.
|
extensions.
|
||||||
@ -104,10 +115,20 @@ class VideoLooper(object):
|
|||||||
# Skip paths that don't exist or are files.
|
# Skip paths that don't exist or are files.
|
||||||
if not os.path.exists(path) or not os.path.isdir(path):
|
if not os.path.exists(path) or not os.path.isdir(path):
|
||||||
continue
|
continue
|
||||||
|
# Ignore hidden files (useful when file loaded on usb
|
||||||
|
# key from an OSX computer
|
||||||
movies.extend(['{0}/{1}'.format(path.rstrip('/'), x) \
|
movies.extend(['{0}/{1}'.format(path.rstrip('/'), x) \
|
||||||
for x in os.listdir(path) \
|
for x in os.listdir(path) \
|
||||||
if re.search('\.{0}$'.format(ex), x,
|
if re.search('\.{0}$'.format(ex), x,
|
||||||
flags=re.IGNORECASE)])
|
flags=re.IGNORECASE) and \
|
||||||
|
x[0] is not '.'])
|
||||||
|
# Get the video volume from the file in the usb key
|
||||||
|
sound_vol_file_path = '{0}/{1}'.format(path.rstrip('/'), self._sound_vol_file)
|
||||||
|
if os.path.exists(sound_vol_file_path):
|
||||||
|
with open(sound_vol_file_path, 'r') as sound_file:
|
||||||
|
sound_vol_string = sound_file.readline()
|
||||||
|
if self._is_number(sound_vol_string):
|
||||||
|
self._sound_vol = int(float(sound_vol_string))
|
||||||
# Create a playlist with the sorted list of movies.
|
# Create a playlist with the sorted list of movies.
|
||||||
return Playlist(sorted(movies))
|
return Playlist(sorted(movies))
|
||||||
|
|
||||||
@ -193,7 +214,7 @@ class VideoLooper(object):
|
|||||||
if movie is not None:
|
if movie is not None:
|
||||||
# Start playing the first available movie.
|
# Start playing the first available movie.
|
||||||
self._print('Playing movie: {0}'.format(movie))
|
self._print('Playing movie: {0}'.format(movie))
|
||||||
self._player.play(movie, loop=playlist.length() == 1)
|
self._player.play(movie, loop=playlist.length() == 1, vol = self._sound_vol)
|
||||||
# Check for changes in the file search path (like USB drives added)
|
# Check for changes in the file search path (like USB drives added)
|
||||||
# and rebuild the playlist.
|
# and rebuild the playlist.
|
||||||
if self._reader.is_changed():
|
if self._reader.is_changed():
|
||||||
@ -203,7 +224,7 @@ class VideoLooper(object):
|
|||||||
playlist = self._build_playlist()
|
playlist = self._build_playlist()
|
||||||
self._prepare_to_run_playlist(playlist)
|
self._prepare_to_run_playlist(playlist)
|
||||||
# Give the CPU some time to do other tasks.
|
# Give the CPU some time to do other tasks.
|
||||||
time.sleep(0)
|
time.sleep(0.002)
|
||||||
|
|
||||||
def signal_quit(self, signal, frame):
|
def signal_quit(self, signal, frame):
|
||||||
"""Shut down the program, meant to by called by signal handler."""
|
"""Shut down the program, meant to by called by signal handler."""
|
||||||
|
@ -34,6 +34,7 @@ rm -rf pi_hello_video
|
|||||||
|
|
||||||
echo "Installing video_looper program..."
|
echo "Installing video_looper program..."
|
||||||
echo "=================================="
|
echo "=================================="
|
||||||
|
mkdir -p /mnt/usbdrive0 # This is very important if you put your system in readonly after
|
||||||
python setup.py install --force
|
python setup.py install --force
|
||||||
cp video_looper.ini /boot/video_looper.ini
|
cp video_looper.ini /boot/video_looper.ini
|
||||||
|
|
||||||
|
1
remount_rw_usbkey.sh
Executable file
1
remount_rw_usbkey.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
sudo mount -o remount ,rw /mnt/usbdrive0
|
@ -79,6 +79,11 @@ sound = both
|
|||||||
#sound = hdmi
|
#sound = hdmi
|
||||||
#sound = local
|
#sound = local
|
||||||
|
|
||||||
|
# Sound volume output for the video player will be read from a file near the
|
||||||
|
# video files. If the file does not exist, a default volume of 0db will be used
|
||||||
|
|
||||||
|
sound_vol_file = sound_volume
|
||||||
|
|
||||||
# Any extra command line arguments to pass to omxplayer. It is not recommended
|
# Any extra command line arguments to pass to omxplayer. It is not recommended
|
||||||
# that you change this unless you have a specific need to do so! The audio and
|
# that you change this unless you have a specific need to do so! The audio and
|
||||||
# video FIFO buffers are kept low to reduce clipping ends of movie at loop.
|
# video FIFO buffers are kept low to reduce clipping ends of movie at loop.
|
||||||
|
Loading…
Reference in New Issue
Block a user