Files
DemonEditor/app/tools/media.py

54 lines
1.2 KiB
Python
Raw Normal View History

2018-04-29 01:44:28 +03:00
from app.tools import vlc
class Player:
_VLC_INSTANCE = None
2018-09-18 07:13:32 +03:00
def __init__(self):
self._is_playing = False
self._player = self.get_vlc_instance()
2018-04-29 01:44:28 +03:00
@staticmethod
def get_vlc_instance():
if Player._VLC_INSTANCE:
return Player._VLC_INSTANCE
2018-10-01 20:16:05 +03:00
_VLC_INSTANCE = vlc.Instance("--quiet --no-xlib").media_player_new()
2018-04-29 01:44:28 +03:00
return _VLC_INSTANCE
2018-09-18 07:13:32 +03:00
def play(self, mrl=None):
if not self._is_playing:
if mrl:
self._player.set_mrl(mrl)
2018-04-29 01:44:28 +03:00
self._player.play()
2018-09-18 07:13:32 +03:00
self._is_playing = True
2018-04-29 01:44:28 +03:00
2018-09-18 07:13:32 +03:00
def stop(self):
if self._is_playing:
2018-04-29 01:44:28 +03:00
self._player.stop()
2018-09-18 07:13:32 +03:00
self._is_playing = False
2018-05-19 16:24:20 +03:00
2018-09-18 07:13:32 +03:00
def pause(self):
self._player.pause()
2018-05-19 16:24:20 +03:00
2018-09-18 07:13:32 +03:00
def release(self):
if self._player:
self._is_playing = False
self._player.stop()
self._player.release()
2018-05-19 16:24:20 +03:00
2018-09-18 07:13:32 +03:00
def set_xwindow(self, xid):
self._player.set_xwindow(xid)
2018-05-19 16:24:20 +03:00
2018-09-18 07:13:32 +03:00
def set_mrl(self, mrl):
self._player.set_mrl(mrl)
2018-04-29 01:44:28 +03:00
2018-09-18 07:13:32 +03:00
def is_playing(self):
return self._is_playing
2018-04-29 01:44:28 +03:00
2018-09-18 07:13:32 +03:00
def set_full_screen(self, full):
self._player.set_fullscreen(full)
2018-04-29 01:44:28 +03:00
if __name__ == "__main__":
2018-09-18 07:13:32 +03:00
pass