-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplayer.py
56 lines (41 loc) · 891 Bytes
/
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
#-*- coding: utf-8 -*-
import os
import re
import time
last_URI=''
play_conf='/root/play/plt.txt'
def is_running():
return True
def stop_player():
#cmdstr='killall tvplayer.sh'
#os.system(cmdstr)
#cmdstr='killall omxplayer.bin'
#os.system(cmdstr)
f=open('/root/playerctrl','w+')
f.write('q')
f.close()
time.sleep(1)
def start_player(URI):
stop_player()
last_URI=URI
if len(URI)>0:
if URI == 'TV':
os.system('/root/play/tvplayer.sh http://localhost/index.m3u8 &')
else:
playcmd='/root/play/tvplayer.sh %s &'%URI
os.system(playcmd)
def start_check_player():
last_info=''
while True:
if os.path.exists(play_conf):
f.open(play_conf,'r')
info=f.read(300)
f.close()
if info != last_info:
last_info = info
if len(info)>0:
start_player(info)
else:
stop_player()
else:
time.sleep(1)