No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

video.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Licensed under GPLv3
  2. # Written by Sebastian Lohff (seba@someserver.de)
  3. # http://seba-geek.de/projects/seopardy/
  4. from __future__ import print_function
  5. from PySide import phonon
  6. class VideoPlayer(object):
  7. def __init__(self, video, audio=False):
  8. self._videoFile = video
  9. self._audio = audio
  10. self._widget = None
  11. self._media_obj = phonon.Phonon.MediaObject()
  12. self._media_src = phonon.Phonon.MediaSource(self._videoFile)
  13. self._audio_out = None
  14. # setup media object
  15. self._media_obj.setCurrentSource(self._media_src)
  16. # make media object loop
  17. self._media_obj.finished.connect(lambda: self._media_obj.play())
  18. if self._audio:
  19. self._audio_out = phonon.Phonon.AudioOutput(phonon.Phonon.VideoCategory)
  20. phonon.Phonon.createPath(self._media_obj, self._audio_out)
  21. def get_widget(self):
  22. if self._widget == None:
  23. self._widget = phonon.Phonon.VideoWidget()
  24. self._widget.setScaleMode(phonon.Phonon.VideoWidget.ScaleAndCrop)
  25. phonon.Phonon.createPath(self._media_obj, self._widget)
  26. return self._widget
  27. def play(self):
  28. self._media_obj.play()
  29. def pause(self):
  30. self._media_obj.pause()
  31. def stop(self):
  32. self._media_obj.stop()