From b27bdb2f0d87df57d36fccd736d1d3b731205b40 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.comā©> Date: Tue, 5 Sep 2023 00:14:27 +0200 Subject: [PATCH] slidertest: stop auto updating if music paused --- apps/slidertest/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/slidertest/app.js b/apps/slidertest/app.js index f27795e3c3..3b178f43de 100644 --- a/apps/slidertest/app.js +++ b/apps/slidertest/app.js @@ -33,7 +33,7 @@ let initSlider2 = ()=>{ {useMap:true, steps:trackDur, currLevel:trackPosition, horizontal:true, rounded:false, timeout:0, useIncr:false, immediateDraw:false, propagateDrag:true, width:Math.round(R.w/20), xStart:R.x2-R.w/20-4, oversizeR:10, oversizeL:10, autoProgress:true, yStart: R.x+4, height: R.w-8} ); sliderObject2.f.draw(sliderObject2.v.level); - sliderObject2.f.startAutoUpdate(); + if (trackState==="play") sliderObject2.f.startAutoUpdate(); } let init = ()=> { @@ -49,10 +49,12 @@ Bangle.musicControl("volumegetlevel"); // Bangle.emit("message", type, msg); let trackPosition = 0; let trackDur = 30; +let trackState = "play"; let messageHandler = (type, msg)=>{ print(type, msg); if (type='music'){ - trackPosition = msg.position+1; // +1 to account for latency. + trackState = msg.state; + trackPosition = msg.position+trackState==="play"?1:0; // +1 to account for latency. trackDur = msg.dur; print('trackPosition: ' + trackPosition) if (sliderObject2) {