1

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?

1

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

Source: http://subupi.blogspot.nl/2012/10/piping-across-shell-sessions-to-control.html

0

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')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.