Reputation: 29
I'm trying to control omxplayer on the command line on my rpi3 using a python script, I call subprocess.Popen and to control it (eg. play/pause, increase/decrease volume, etc..) I should write a character to stdin (eg. p, +/-, etc..), the character is passed in send_signal as variable text, using communicate I can't control it, is there a better way?
EDIT: Also player.stdin.write(text); player.stdin.flush() doesn't work.
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()
trying with cat -e instead of omxplayer the output is:
why_dont_you work
test_input
test_input$
test_input2
test_input2$
a
a$
note that the first line somehow is not shown again
Upvotes: 1
Views: 1771