You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • You just need to define a function called GB:

    1. global.GB = (event) => {
    2. switch (event.t) {
    3. case "musicinfo":
    4. ...
    5. break;
    6. case "musicstate":
    7. ...
    8. break;
    9. }
    10. };

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

  • This would override the GB function if it's already defined, correct? What if multiple apps want to receive events?

  • 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.

    1. global.GB = function(j) {
    2. if (debug ==1) print("global.GB");
    3. switch (j.t) {
    4. case "musicinfo":
    5. musicInfo = j;
    6. draw();
    7. break;
    8. case "musicstate":
    9. musicState = j.state;
    10. draw();
    11. break;
    12. }
    13. };
About

Avatar for Gordon @Gordon started