Mplayer.py 699 B

123456789101112131415161718192021222324252627282930
  1. import logging
  2. import os
  3. import subprocess
  4. logging.basicConfig()
  5. logger = logging.getLogger("kalliope")
  6. MPLAYER_EXEC_PATH = "/usr/bin/mplayer"
  7. class Mplayer(object):
  8. def __init__(self):
  9. mplayer_exec_path = [MPLAYER_EXEC_PATH]
  10. mplayer_options = ['-slave', '-quiet']
  11. self.mplayer_command = list()
  12. self.mplayer_command.extend(mplayer_exec_path)
  13. self.mplayer_command.extend(mplayer_options)
  14. def play(self, filepath):
  15. self.mplayer_command.append(filepath)
  16. logger.debug("Mplayer cmd: %s" % str(self.mplayer_command))
  17. FNULL = open(os.devnull, 'w')
  18. subprocess.call(self.mplayer_command, stdout=FNULL, stderr=FNULL)