From b7fa80bb13ae124f817566d3b1eeee11ce83abc8 Mon Sep 17 00:00:00 2001 From: Tobias Perschon Date: Thu, 1 Aug 2024 18:25:30 +0200 Subject: [PATCH] v1.0.19 (#227) * added option to disable keyboard / gpio control while playback --- Adafruit_Video_Looper/video_looper.py | 11 +++++++++++ README.md | 5 ++++- assets/video_looper.ini | 12 +++++++++++- setup.py | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Adafruit_Video_Looper/video_looper.py b/Adafruit_Video_Looper/video_looper.py index e9565e9..f4dce31 100644 --- a/Adafruit_Video_Looper/video_looper.py +++ b/Adafruit_Video_Looper/video_looper.py @@ -61,6 +61,8 @@ def __init__(self, config_path): self._play_on_startup = self._config.getboolean('video_looper', 'play_on_startup') self._resume_playlist = self._config.getboolean('video_looper', 'resume_playlist') self._keyboard_control = self._config.getboolean('control', 'keyboard_control') + self._keyboard_control_disabled_while_playback = self._config.getboolean('control', 'keyboard_control_disabled_while_playback') + self._gpio_control_disabled_while_playback = self._config.getboolean('control', 'gpio_control_disabled_while_playback') self._copyloader = self._config.getboolean('copymode', 'copyloader') # Get seconds for countdown from config self._countdown_time = self._config.getint('video_looper', 'countdown_time') @@ -429,6 +431,11 @@ def _set_hardware_volume(self): def _handle_keyboard_shortcuts(self): while self._running: event = pygame.event.wait() + + if self._keyboard_control_disabled_while_playback and self._player.is_playing(): + self._print(f'keyboard control disabled while playback is running') + continue + if event.type == pygame.KEYDOWN: # If pressed key is ESC quit program if event.key == pygame.K_ESCAPE: @@ -470,6 +477,10 @@ def _handle_gpio_control(self, pin): if self._pinMap == None: return + if self._gpio_control_disabled_while_playback and self._player.is_playing(): + self._print(f'gpio control disabled while playback is running') + return + action = self._pinMap[str(pin)] self._print(f'pin {pin} triggered: {action}') diff --git a/README.md b/README.md index 4439b3a..b1a165b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ For a detailed tutorial visit: (but they might not always contain the latest version of pi_video_looper) ## Changelog +#### new in v1.0.19 + - keyboard and gpio control can now be disabled while a video is running - makes the most sense together with the "one shot playback" setting + #### v1.0.18 - fixed one-shot playback with only one video file - added option to not start video playback on looper startup (boot) @@ -187,7 +190,7 @@ The following keyboard commands are active by default (can be disabled in the [v #### GPIO control: To enable GPIO control you need to set a GPIO pin mapping via the `gpio_pin_map` in the `control` section of the video_looper.ini. -Pins numbers are in "BOARD" numbering - see: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html. Bridge a mapped pin with a Ground pin to trigger it. +Pins numbers are in "BOARD" numbering - see: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio. Bridge a mapped pin with a Ground pin to trigger it. The pin mapping has the form: "pinnumber" : "action”. The action can be one of the following: * a filename as a string to play diff --git a/assets/video_looper.ini b/assets/video_looper.ini index 073e722..69e1d77 100644 --- a/assets/video_looper.ini +++ b/assets/video_looper.ini @@ -126,8 +126,13 @@ console_output = false keyboard_control = true #keyboard_control = false +# you can disable the keyboard control while a video is playing - in case of a looping video keyboard control will never work +# is meant to be used with one_shot_playback +keyboard_control_disabled_while_playback = false +#keyboard_control_disabled_while_playback = true + # This setting defines which Raspberry Pi GPIO pin (BOARD numbering!) will jump to which file in the playlist (first file has index 0) -# See: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html for info about the pin numbers +# See: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio for info about the pin numbers # the pins are pulled high so you need to connect your switch to the selected pin and Ground (e.g. pin 9) - there is some debouncing done in software # The accepted settings are like this: "pinnumber" : videoindex or "pinnumber" : "filename" or "pinnumber" : "-1" or "pinnumber" : "+1" # its also possible to send "keyboard commands" like shutdown or pause (see readme for available keyboard commands) @@ -144,6 +149,11 @@ gpio_pin_map = # pin 19 sends the "spacebar" to the looper, pausing the current video # pin 21 sends the "p" key and thus triggers the shutdown of the Raspberry Pi +# you can disable the gpio control while a video is playing - in case of a looping video gpio control will never work +# is meant to be used with one_shot_playback +gpio_control_disabled_while_playback = false +#gpio_control_disabled_while_playback = true + # USB drive file reader configuration follows. [usb_drive] diff --git a/setup.py b/setup.py index c3eecf1..6a572d3 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages setup(name = 'Adafruit_Video_Looper', - version = '1.0.18', + version = '1.0.19', author = 'Tony DiCola', author_email = 'tdicola@adafruit.com', description = 'Application to turn your Raspberry Pi into a dedicated looping video playback device, good for art installations, information displays, or just playing cat videos all day.',