Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending keystroke to a process

I want to write a seperate program that can receive commands from network and replay these commands to omxplayer. omxplayer is the video player on raspberry pi, we can control omxplayer via the keystroke. May anyone please suggest some approaches that we can send keystroke event to a running process?

Any suggestions are appreciated. Thanks!

like image 573
Dien Nguyen Avatar asked Sep 15 '13 01:09

Dien Nguyen


1 Answers

You can use FIFO to send keystrokes to omxplayer.

We'll show you a basic example of how you do it.

In Shell (Terminal 1),

mkfifo /path/to/dir/fifo
omxplayer /path/to/movie/dir/movie.ext < /path/to/dir/fifo

after you execute these commands, the terminal 1 will hold.

Now in terminal 2

echo -n . > /path/to/dir/fifo

now it will start play.

This was the basic example. You can create a php file to write to the fifo file. So from that you can send commands.

p will pause

q will quit

also, when using non-letter commands (like up arrow, and down arrow), you should send the correct key code.

Hope this helps.

like image 53
user1479203 Avatar answered Oct 30 '22 19:10

user1479203