-
Notifications
You must be signed in to change notification settings - Fork 4
/
player.py
63 lines (46 loc) · 1.8 KB
/
player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
import subprocess
import shutil
import sys
from custom_logger import CustomLogger
log = CustomLogger(__name__)
class Player:
def __init__(self, url):
self.url = url
# Check for mpv
if shutil.which('mpv') is None:
log.error('Could not found mpv program on your system')
sys.exit(1)
def play(self):
# We start mpv with the video
p = subprocess.Popen(['mpv', self.url], shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(output, err) = p.communicate()
retval = p.wait()
# print('MPV_STDOUT: \n' + output.decode('utf-8'))
# if not CONFIG['disable_video_player']:
# # We start mpv with the video
# p = subprocess.Popen(['mpv', runtime.CURRENT_PATH[-1]['video']['url']], shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# output = ''
# if CONFIG['auto_exploration']:
# # We need to stop the video after some time
# time.sleep(5)
# p.send_signal(signal.SIGINT)
# (output, err) = p.communicate()
# retval = p.wait() # Maybe not needed?
# else:
# # The user need to manually close mpv
# (output, err) = p.communicate()
# retval = p.wait()
# MPV_STDOUT = output.decode('utf-8')
# # print('MPV_STDOUT: \n' + MPV_STDOUT)
# if 'Exiting... (Quit)' not in MPV_STDOUT:
# print(WARNING + ' This video does not seem to work (see log above) ' + WARNING)
# print('')
# runtime.ALL_REPORTED_ERROR.append({
# 'type': 'Video',
# 'path': current_path_pp(runtime.CURRENT_PATH),
# 'route': bridge.TRIGGER_ERROR_ROUTE,
# 'params': bridge.TRIGGER_ERROR_PARAMS
# })
# if CONFIG['exit_on_error']:
# next_item = -1