1
私はrpi3のコマンドラインでpythonスクリプトを使ってomxplayerを制御しようとしています。私はsubprocess.Popenを呼び出してそれを制御します(例えば、再生/一時停止、ボリュームの増減、 )私はstdin(例えば、p、+/-、など..)に文字を書く必要があります、文字は変数テキストとしてsend_signalに渡されます、私はそれを制御することはできません通信、よりよい方法はありますか?サブプロセスに文字を送信する.Popen
EDIT:また、player.stdin.write(text); player.stdin.flush()は機能しません。猫としよう
def start_music():
player = subprocess.Popen(['omxplayer', songs[0]], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
return player
def send_signal(player, text):
player.communicate(text.encode('utf-8'))
player.stdin.close()
出力があるomxplayer -eの代わり:
why_dont_you work
test_input
test_input$
test_input2
test_input2$
a
a$
ノート最初の行は何とか再び
omxplayerはGUIまたはコマンドラインプログラムですか? –
@NickTコマンドラインで – kknickkk
'player.stdin.write(text);を試したことがありますか? player.stdin.flush() '? –