better code for "previous"
This commit is contained in:
+10
-13
@@ -43,19 +43,16 @@ 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('mocp --previous')
|
||||||
logging.debug(int(position))
|
subprocess.call(["mocp", "--previous"])
|
||||||
if (int(position) < 4):
|
else:
|
||||||
logging.debug('mocp --previous')
|
logging.debug('mocp --jump 0s')
|
||||||
subprocess.call(["mocp", "--previous"])
|
subprocess.call(["mocp", "--jump", "0s"])
|
||||||
else:
|
|
||||||
logging.debug('mocp --jump 0s')
|
|
||||||
subprocess.call(["mocp", "--jump", "0s"])
|
|
||||||
|
|
||||||
def btn2_callback(channel):
|
def btn2_callback(channel):
|
||||||
logging.debug('mocp --toggle-pause')
|
logging.debug('mocp --toggle-pause')
|
||||||
|
|||||||
Reference in New Issue
Block a user