Merge branch 'master' of https://github.com/subicura/pi_video_looper into subicura-master
This commit is contained in:
commit
22b11b4165
@ -1,13 +1,16 @@
|
|||||||
# Copyright 2015 Adafruit Industries.
|
# Copyright 2015 Adafruit Industries.
|
||||||
# Author: Tony DiCola
|
# Author: Tony DiCola
|
||||||
# License: GNU GPLv2, see LICENSE.txt
|
# License: GNU GPLv2, see LICENSE.txt
|
||||||
|
import random
|
||||||
|
|
||||||
class Playlist(object):
|
class Playlist(object):
|
||||||
"""Representation of a playlist of movies."""
|
"""Representation of a playlist of movies."""
|
||||||
|
|
||||||
def __init__(self, movies):
|
def __init__(self, movies, is_random):
|
||||||
"""Create a playlist from the provided list of movies."""
|
"""Create a playlist from the provided list of movies."""
|
||||||
self._movies = movies
|
self._movies = movies
|
||||||
self._index = None
|
self._index = None
|
||||||
|
self._is_random = is_random
|
||||||
|
|
||||||
def get_next(self):
|
def get_next(self):
|
||||||
"""Get the next movie in the playlist. Will loop to start of playlist
|
"""Get the next movie in the playlist. Will loop to start of playlist
|
||||||
@ -16,6 +19,10 @@ class Playlist(object):
|
|||||||
# Check if no movies are in the playlist and return nothing.
|
# Check if no movies are in the playlist and return nothing.
|
||||||
if len(self._movies) == 0:
|
if len(self._movies) == 0:
|
||||||
return None
|
return None
|
||||||
|
# Start Random movie
|
||||||
|
if self._is_random:
|
||||||
|
self._index = random.randrange(0, len(self._movies))
|
||||||
|
else:
|
||||||
# Start at the first movie and increment through them in order.
|
# Start at the first movie and increment through them in order.
|
||||||
if self._index is None:
|
if self._index is None:
|
||||||
self._index = 0
|
self._index = 0
|
||||||
@ -24,6 +31,7 @@ class Playlist(object):
|
|||||||
# Wrap around to the start after finishing.
|
# Wrap around to the start after finishing.
|
||||||
if self._index >= len(self._movies):
|
if self._index >= len(self._movies):
|
||||||
self._index = 0
|
self._index = 0
|
||||||
|
|
||||||
return self._movies[self._index]
|
return self._movies[self._index]
|
||||||
|
|
||||||
def length(self):
|
def length(self):
|
||||||
|
@ -53,6 +53,7 @@ class VideoLooper(object):
|
|||||||
self._reader = self._load_file_reader()
|
self._reader = self._load_file_reader()
|
||||||
# Load other configuration values.
|
# Load other configuration values.
|
||||||
self._osd = self._config.getboolean('video_looper', 'osd')
|
self._osd = self._config.getboolean('video_looper', 'osd')
|
||||||
|
self._is_random = self._config.getboolean('video_looper', 'is_random')
|
||||||
# Parse string of 3 comma separated values like "255, 255, 255" into
|
# Parse string of 3 comma separated values like "255, 255, 255" into
|
||||||
# list of ints for colors.
|
# list of ints for colors.
|
||||||
self._bgcolor = map(int, self._config.get('video_looper', 'bgcolor') \
|
self._bgcolor = map(int, self._config.get('video_looper', 'bgcolor') \
|
||||||
@ -130,7 +131,7 @@ class VideoLooper(object):
|
|||||||
if self._is_number(sound_vol_string):
|
if self._is_number(sound_vol_string):
|
||||||
self._sound_vol = int(float(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), self._is_random)
|
||||||
|
|
||||||
def _blank_screen(self):
|
def _blank_screen(self):
|
||||||
"""Render a blank screen filled with the background color."""
|
"""Render a blank screen filled with the background color."""
|
||||||
|
@ -33,6 +33,9 @@ file_reader = usb_drive
|
|||||||
osd = true
|
osd = true
|
||||||
#osd = false
|
#osd = false
|
||||||
|
|
||||||
|
# To play random playlist.
|
||||||
|
is_random = false
|
||||||
|
|
||||||
# Change the color of the background that is displayed behind movies (only works
|
# Change the color of the background that is displayed behind movies (only works
|
||||||
# with omxplayer). Provide 3 numeric values from 0 to 255 separated by a commma
|
# with omxplayer). Provide 3 numeric values from 0 to 255 separated by a commma
|
||||||
# for the red, green, and blue color value. Default is 0, 0, 0 or black.
|
# for the red, green, and blue color value. Default is 0, 0, 0 or black.
|
||||||
|
Loading…
Reference in New Issue
Block a user