player.py 921 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!./bin/python3
  2. from display import Display
  3. from typing import Dict
  4. from pymplb import MPlayer
  5. class Player(Display):
  6. '''
  7. Player object
  8. '''
  9. def __init__(self, config, pydsp):
  10. super().__init__({
  11. "dimx" : config.get("dimx"),
  12. "dimx" : config.get("dimy"),
  13. "playlist" : config.get("dimy"),
  14. "fontsize" : config.get("fontsize"),
  15. }, pydsp)
  16. self._player = MPlayer()
  17. def setData(self, data: Dict):
  18. self._data = data
  19. def loadPlaylist(self) -> Dict:
  20. return self._data
  21. def togglePlay(self):
  22. if not self._current_item:
  23. return
  24. if self._player.p_path == self._current_item["path"]:
  25. print("stop")
  26. self._player.stop()
  27. else:
  28. print("Playing:", self._current_item)
  29. self._player.loadfile(self._current_item["path"])