Skip to content

Commit

Permalink
spotrem: add timeout to wait for values from GB
Browse files Browse the repository at this point in the history
... getting the current volume level from android.
  • Loading branch information
thyttan committed Aug 17, 2023
1 parent eaffdf4 commit c9b4f24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/spotrem/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ let audioHandler = (e)=>{audioLevels = e; print(audioLevels);};
Bangle.on('audio', audioHandler);
Bangle.musicControl("volumegetlevel");

let tempMask = ()=>{E.stopEventPropagation&&E.stopEventPropagation(); setTimeout(()=>{Bangle.removeListener('drag',tempMask);}, 150);}; // FIXME: Temporary fix/hack before redoing input to not rely on setUI's "updown" mode.

// Navigation input on the main layout
let setUI = function() {
// Bangle.setUI code from rigrig's smessages app for volume control: https://git.tubul.net/rigrig/BangleApps/src/branch/personal/apps/smessages/app.js
Expand All @@ -119,12 +121,14 @@ let setUI = function() {
//if (ud) Bangle.musicControl(ud>0 ? "volumedown" : "volumeup");

if (ud) {
Bangle.prependListener('drag', tempMask);

let callback = (mode, fb)=>{
if (mode == "map") Bangle.musicControl({cmd:"volumesetlevel", extra:Math.round(100*fb/30)});
if (mode == "incr") Bangle.musicControl(fb>0 ? "volumedown" : "volumeup");
if (mode =="remove") {audioLevels.c = fb; print(audioLevels.c);}
};
require("SliderInput").interface(callback, {useMap:true, oversizeL:0.25, steps:audioLevels.u, currLevel:audioLevels.c});
setTimeout(()=>{require("SliderInput").interface(callback, {useMap:true, steps:audioLevels.u, currLevel:audioLevels.c});},200);
}
}
);
Expand Down

0 comments on commit c9b4f24

Please sign in to comment.