Browse Source

Fix spacing & close sound file.

pull/16/head
Tony DiCola 9 years ago
parent
commit
6cd7a794a0
2 changed files with 20 additions and 21 deletions
  1. +2
    -2
      Adafruit_Video_Looper/omxplayer.py
  2. +18
    -19
      Adafruit_Video_Looper/video_looper.py

+ 2
- 2
Adafruit_Video_Looper/omxplayer.py View File

@@ -34,8 +34,8 @@ class OMXPlayer(object):
args = ['omxplayer']
args.extend(['-o', self._sound]) # Add sound arguments.
args.extend(self._extra_args) # Add extra arguments from config.
if vol is not 0:
args.extend(['--vol', str(vol)])
if vol is not 0:
args.extend(['--vol', str(vol)])
if loop:
args.append('--loop') # Add loop parameter if necessary.
args.append(movie) # Add movie file path.


+ 18
- 19
Adafruit_Video_Looper/video_looper.py View File

@@ -62,10 +62,10 @@ class VideoLooper(object):
.translate(None, ',') \
.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_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.font.init()
pygame.mouse.set_visible(False)
@@ -96,11 +96,11 @@ class VideoLooper(object):
.create_file_reader(self._config)

def _is_number(iself, s):
try:
float(s)
return True
except ValueError:
return False
try:
float(s)
return True
except ValueError:
return False
def _build_playlist(self):
"""Search all the file reader paths for movie files with the provided
@@ -115,23 +115,22 @@ class VideoLooper(object):
# Skip paths that don't exist or are files.
if not os.path.exists(path) or not os.path.isdir(path):
continue
# Ignore hidden files (useful when file loaded on usb
# key from an OSX computer
# Ignore hidden files (useful when file loaded on usb
# key from an OSX computer
movies.extend(['{0}/{1}'.format(path.rstrip('/'), x) \
for x in os.listdir(path) \
if re.search('\.{0}$'.format(ex), x,
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):
sound_file = open(sound_vol_file_path, 'r')
sound_vol_string = sound_file.readline()
if self._is_number(sound_vol_string):
self._sound_vol = int(float(sound_vol_string))
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.
return Playlist(sorted(movies))

def _blank_screen(self):
"""Render a blank screen filled with the background color."""


Loading…
Cancel
Save