Currently I am using omxplayer to open videos and audios. It works really well.I can pause the video using p/spacebar and other key bindings. My question is how to stop/pause/fast forward by using python script?
I wanted to do the same thing in NodeJS, the way i handled this was to pipe the keyboard input into omxplayer from the command line.
First make a special FIFO ( first in first out ) file. Then we can use this file to pipe "hotkeys" to omxplayer. Anything we write comes out in the order the file is read. The second command cats the output of this and pipes it into omxplayer.
mkfifo t cat t | omxplayer --no-osd -b myvideo.mp4 &
Then to pause: ( 'rm t' removes the FIFO file )
echo p > t rm t
Heres an example using rofavadeka's method:
import os os.system('mkfifo t cat t | omxplayer --no-osd -b myvideo.mp4 &') def play_pause(): os.system('echo p > t rm t')