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