Skip to content

Instantly share code, notes, and snippets.

@paulzhol
Created April 13, 2013 16:15
Show Gist options
  • Save paulzhol/5379023 to your computer and use it in GitHub Desktop.
Save paulzhol/5379023 to your computer and use it in GitHub Desktop.
Launcher script for XBMC external mplayer-vaapi. First argument is the XBMC pid, the second is the filename to play. The script will send a SIGSTOP to the XBMC process, wait for mplayer to exit and send SIGCONT to resume XBMC.
#!/usr/bin/env python
import sys
import os
import signal
import shlex
MPLAYER_PATH='/opt/mplayer-vaapi/bin/mplayer'
MPLAYER_OPTS='-vo vaapi:glfinish -ao alsa:noblock:device=hw=0.3 -fs -slang en -subfont-text-scale 2 -subpos 100'
if __name__ == '__main__':
xbmc_pid = int(sys.argv[1])
url = sys.argv[2]
pid = os.fork()
if pid == 0:
args = [MPLAYER_PATH]+shlex.split(MPLAYER_OPTS)+[url]
os.execv(MPLAYER_PATH, args);
sys.exit(-1)
else:
os.kill(xbmc_pid, signal.SIGSTOP)
os.waitpid(pid, 0)
os.kill(xbmc_pid, signal.SIGCONT)
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment