Browse Source

Merge branch 'master' of https://github.com/subicura/pi_video_looper into subicura-master

pull/16/head
Tony DiCola 9 years ago
parent
commit
22b11b4165
3 changed files with 21 additions and 9 deletions
  1. +16
    -8
      Adafruit_Video_Looper/model.py
  2. +2
    -1
      Adafruit_Video_Looper/video_looper.py
  3. +3
    -0
      video_looper.ini

+ 16
- 8
Adafruit_Video_Looper/model.py View File

@@ -1,13 +1,16 @@
# Copyright 2015 Adafruit Industries.
# Author: Tony DiCola
# License: GNU GPLv2, see LICENSE.txt
import random

class Playlist(object):
"""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."""
self._movies = movies
self._index = None
self._is_random = is_random

def get_next(self):
"""Get the next movie in the playlist. Will loop to start of playlist
@@ -16,14 +19,19 @@ class Playlist(object):
# Check if no movies are in the playlist and return nothing.
if len(self._movies) == 0:
return None
# Start at the first movie and increment through them in order.
if self._index is None:
self._index = 0
# Start Random movie
if self._is_random:
self._index = random.randrange(0, len(self._movies))
else:
self._index += 1
# Wrap around to the start after finishing.
if self._index >= len(self._movies):
self._index = 0
# Start at the first movie and increment through them in order.
if self._index is None:
self._index = 0
else:
self._index += 1
# Wrap around to the start after finishing.
if self._index >= len(self._movies):
self._index = 0

return self._movies[self._index]

def length(self):


+ 2
- 1
Adafruit_Video_Looper/video_looper.py View File

@@ -53,6 +53,7 @@ class VideoLooper(object):
self._reader = self._load_file_reader()
# Load other configuration values.
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
# list of ints for colors.
self._bgcolor = map(int, self._config.get('video_looper', 'bgcolor') \
@@ -130,7 +131,7 @@ class VideoLooper(object):
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))
return Playlist(sorted(movies), self._is_random)

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


+ 3
- 0
video_looper.ini View File

@@ -33,6 +33,9 @@ file_reader = usb_drive
osd = true
#osd = false

# To play random playlist.
is_random = false

# 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
# for the red, green, and blue color value. Default is 0, 0, 0 or black.


Loading…
Cancel
Save