I’m using omxplayer on the Raspberry Pi for video playback because it utilizes the Raspberry Pi’s hardware video decoding.
Because the front-end is a separate application, I just need to remote control OMX Player to start and stop the video and figure out how far the video has played back already.

Originally I used the pyomxplayer project and some of its forks (e.g. Bounder’s fork) because the original was outdated and the newer OMXPlayer binaries have other command line flags.

My goal for this player was not so much the interactive control of the video playback as full programmatic control and introspection into the playback and appropriate reaction with events.

The most relevant events for me are:

Startup

Did it start up and playback start? on_start

Why did it not start, e.g. input file not found, corrupt, etc. on_error

Playback

Has it started playing? -> on_start

What is the play state -> playing

Based on those I could then do a stripped down version for my purposes that allows fine-grained monitoring.

Release to Github pending. I’ll update the article when it’s done.

Another important thing for me was to use daemon threads for the monitoring, as the controlling application is interactive and could technically stop at any time. I don’t want it blocked until the video finally stops by itself.