Browse Source

Add option for a background image

pull/16/head
Emmanuel Geoffray 9 years ago
parent
commit
33bf52c78d
2 changed files with 20 additions and 1 deletions
  1. +16
    -1
      Adafruit_Video_Looper/video_looper.py
  2. +4
    -0
      video_looper.ini

+ 16
- 1
Adafruit_Video_Looper/video_looper.py View File

@@ -70,8 +70,9 @@ class VideoLooper(object):
pygame.display.init() pygame.display.init()
pygame.font.init() pygame.font.init()
pygame.mouse.set_visible(False) pygame.mouse.set_visible(False)
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
size = self._size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
self._screen = pygame.display.set_mode(size, pygame.FULLSCREEN) self._screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
self._bgimage = self._load_bgimage()
self._blank_screen() self._blank_screen()
# Set other static internal state. # Set other static internal state.
self._extensions = self._player.supported_extensions() self._extensions = self._player.supported_extensions()
@@ -96,6 +97,17 @@ 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 _load_bgimage(self):
"""Load the configured background image and return an instance of it."""
image = None
if self._config.has_option('video_looper', 'bgimage'):
image = self._config.get('video_looper', 'bgimage')
print 'Use ' + str(image) + ' as a background'
image = pygame.image.load(image)
image = pygame.transform.scale(image, self._size)
return image

def _is_number(iself, s): def _is_number(iself, s):
try: try:
float(s) float(s)
@@ -136,6 +148,9 @@ class VideoLooper(object):
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."""
self._screen.fill(self._bgcolor) self._screen.fill(self._bgcolor)
if self._bgimage is not None:
rect = self._bgimage.get_rect()
self._screen.blit(self._bgimage, rect)
pygame.display.update() pygame.display.update()


def _render_text(self, message, font=None): def _render_text(self, message, font=None):


+ 4
- 0
video_looper.ini View File

@@ -36,6 +36,10 @@ osd = true
# To play random playlist. # To play random playlist.
is_random = false is_random = false


# Change the background with a custom image
# This image is displayed between movies
#bgimage = /home/pi/bg.png

# 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…
Cancel
Save