瀏覽代碼

Merge branch 'subicura-master'

pull/16/head
Tony DiCola 9 年之前
父節點
當前提交
b725b0dabe
共有 3 個檔案被更改,包括 21 行新增9 行删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存