1

Currently, I have my pi hooked to the TV and I use it to play movies via ssh. While I love simplicity of tmux and ssh, people around me are not quite excited about it :)

My plan is to have a web-interface running on the pi and hopefully control it from the browser. So I ended up writing a really simple flask app that returns a list of movies and I can play them by launching omxplayer via flask using the sub-process module. Its not terrific or anything, but it works.

The problem though is sending commands to the player! It might be possible by talking to the omxplayer process, but I am not sure how.

Any ideas? I know that I can just use xmbc but wheres the fun in that :)

2 Answers 2

1

In theory, this approach should work.

Try writing to /proc/[PID of process]/fd/0

A process' fd directory handles the file descriptors the process is concerned about. File descriptor 0 is STDIN. 1 is STDOUT and 2 is STDERR.

1

There's a library for that, although from the looks of things it may have a few 'quirks':

https://github.com/willprice/python-omxplayer-wrapper

Hello world example

from omxplayer import OMXPlayer
from time import sleep

# This will start an `omxplayer` process, this might 
# fail the first time you run it, currently in the 
# process of fixing this though.
player = OMXPlayer('path/to/file.mp4')

# The player will initially be paused

player.play()
sleep(5)
player.pause()

# Kill the `omxplayer` process gracefully.
player.quit()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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