123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import RPi.GPIO as GPIO
- import time
- import subprocess
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- while True:
- input_state = GPIO.input(14)
- if input_state == False:
- print('playpause')
- result = subprocess.run(
- [f"python ./player.py playpause"],
- stdout=subprocess.PIPE,
- shell=True,
- ).stdout.decode("utf-8")
- time.sleep(0.2)
- input_state = GPIO.input(15)
- if input_state == False:
- print('next')
- result = subprocess.run(
- [f"python ./player.py next"],
- stdout=subprocess.PIPE,
- shell=True,
- ).stdout.decode("utf-8")
- time.sleep(0.2)
- input_state = GPIO.input(24)
- if input_state == False:
- print('previous')
- result = subprocess.run(
- [f"python ./player.py previous"],
- stdout=subprocess.PIPE,
- shell=True,
- ).stdout.decode("utf-8")
- time.sleep(0.2)
- input_state = GPIO.input(23)
- if input_state == False:
- print('shuffle')
- result = subprocess.run(
- [f"python ./player.py shuffle"],
- stdout=subprocess.PIPE,
- shell=True,
- ).stdout.decode("utf-8")
- time.sleep(0.2)
|