• You just need to define a function called GB:

      global.GB = (event) => {
        switch (event.t) {
          case "musicinfo":
            ...
            break;
          case "musicstate":
            ...
            break;
        }
      };
    

    More info on what form the data takes is at http://www.espruino.com/Gadgetbridge

  • Okay, I saw that code in the BG widget and I am using it in my app.
    However, I do not know how to trigger it.

    The problem is, that I have to read what is playing, when I start the app.
    Otherwise I cannot show title information and I do not know what the musicstate is.

    global.GB = function(j) {
      if (debug ==1) print("global.GB");
      switch (j.t) {
        case "musicinfo":
          musicInfo = j;
          draw();
          break;
        case "musicstate":
          musicState = j.state;
          draw();
          break;
      }
    };
    
About