私は、ボタンが押されると、オーディオファイルが再生されるラズベリーパイにpythonでプログラムを書き込もうとしています。私はomxplayerを実行し、それを適切に閉じるさまざまな方法を試しましたが、どれもうまくいかないようです。すべてのヘルプをいただければ幸いですomxplayerが呼び出された後のPythonコードの処理
TypeError: a bytes-like object is required, not 'str'
:
import RPi.GPIO as GPIO
import time
from time import sleep
import subprocess
BUTTON = 15
GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
while True:
if (GPIO.input(BUTTON)==True):
a = subprocess.Popen(['omxplayer', '-o', 'local', '*.mp3'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
sleep(1)
a.stdin.write('q')
if (/exit process/):
#exit process
現在、私はa.stdin.writeに(Q ')行のエラーが表示されます。次のように私のコードは、現在あります。
'A'は' a.subprocess.Popen'のように、何ですか? – quamrana
申し訳ありませんが、私は= subprocess.Popenを意味します。 –
エラーメッセージはあなたが間違っていることを教えています。 – quamrana