Skip to content

Instantly share code, notes, and snippets.

@appendjeff
Last active April 25, 2017 23:45
Show Gist options
  • Select an option

  • Save appendjeff/ec02d35ed0e9d810f1dc3f70150a2bc5 to your computer and use it in GitHub Desktop.

Select an option

Save appendjeff/ec02d35ed0e9d810f1dc3f70150a2bc5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from subprocess import Popen, PIPE
import time
import RPiGPIO as GPIO
MY_VIDEO_FILE_PATH = '/home/video_name.mp4'
my_process = Popen(['omxplayer', MY_VIDEO_FILE_PATH], stdin=PIPE, close_fds=True, bufsize=0)
GPIO.setmode(GPIO.BCM)
GPIO.setup(22,GPIO.IN,pull_up_down=GPIO.PUD_UP)
while True:
button_state = GPIO.input(22)
if button_state == False:
print('Quitting the player now')
my_process.stdin.write('q')
time.sleep(0.9)
@appendjeff
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment