better code for "previous"
This commit is contained in:
+5
-8
@@ -43,14 +43,11 @@ position = 0
|
|||||||
|
|
||||||
def btn1_callback(channel):
|
def btn1_callback(channel):
|
||||||
logging.debug('PREV_CALLBACK')
|
logging.debug('PREV_CALLBACK')
|
||||||
out, err = subprocess.Popen(['mocp','--info'], stdout=subprocess.PIPE).communicate()
|
out, err = subprocess.Popen(['mocp','-Q', '%state'], stdout=subprocess.PIPE).communicate()
|
||||||
info = out.splitlines()
|
if (out.decode("utf-8").startswith('PLAY')):
|
||||||
for s in info:
|
out, err = subprocess.Popen(['mocp','-Q', '%cs'], stdout=subprocess.PIPE).communicate()
|
||||||
s = s.decode("utf-8")
|
position = int(out.decode("utf-8"))
|
||||||
if s.startswith('CurrentSec'):
|
if (position < 4):
|
||||||
position = s[s.rfind(' ')+1:]
|
|
||||||
logging.debug(int(position))
|
|
||||||
if (int(position) < 4):
|
|
||||||
logging.debug('mocp --previous')
|
logging.debug('mocp --previous')
|
||||||
subprocess.call(["mocp", "--previous"])
|
subprocess.call(["mocp", "--previous"])
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user