Mplayer.py 698 B

1234567891011121314151617181920212223242526272829303132
  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. pass
  10. @classmethod
  11. def play(cls, filepath):
  12. mplayer_exec_path = [MPLAYER_EXEC_PATH]
  13. mplayer_options = ['-slave', '-quiet']
  14. mplayer_command = list()
  15. mplayer_command.extend(mplayer_exec_path)
  16. mplayer_command.extend(mplayer_options)
  17. mplayer_command.append(filepath)
  18. logger.debug("Mplayer cmd: %s" % str(mplayer_command))
  19. FNULL = open(os.devnull, 'w')
  20. subprocess.call(mplayer_command, stdout=FNULL, stderr=FNULL)