function musicState(e) {
  stat = e.state;
  // if paused for five minutes, load the clock
  // (but timeout resets if we get new info, even while paused)
  if (tPxt) {
    clearTimeout(tPxt);
    tPxt = null;
  }
  if (tIxt) {
    clearTimeout(tIxt);
    tIxt = null;
  }
  fade = null;
  if (auto) { // auto opened -> auto close
    switch(stat) {
      case "stop": // never actually happens with my phone :-(
        load();
        break;
      case "play":
        // if inactive for double song duration (or an hour if unknown), load the clock
        // i.e. phone finished playing without bothering to notify the watch
        tIxt = setTimeout(load, (e.dur*2000) || IOUT);
        break;
      case "pause":
      default:
        // quit when paused for a long time
        // also fade out track info while waiting for this
        tPxt = setTimeout(load, POUT);
        fade = Date.now();
        fadeOut();
        break;
    }
  }
  if (BANGLE2 || Bangle.isLCDOn()) {
    drawControls();
  }
}
/**
 * Update music state
 * @param {Object} e - Gadgetbridge musicstate event
 */
Update music state
@param {Object} e - Gadgetbridge musicstate event
Update music state @param { Object } e - Gadgetbridge musicstate event
function musicState(e) {
  stat = e.state;
  if (tPxt) {
    clearTimeout(tPxt);
    tPxt = null;
  }
  if (tIxt) {
    clearTimeout(tIxt);
    tIxt = null;
  }
  fade = null;
  if (auto) { 
    switch(stat) {
      case "stop": 
        load();
        break;
      case "play":
        tIxt = setTimeout(load, (e.dur*2000) || IOUT);
        break;
      case "pause":
      default:
        tPxt = setTimeout(load, POUT);
        fade = Date.now();
        fadeOut();
        break;
    }
  }
  if (BANGLE2 || Bangle.isLCDOn()) {
    drawControls();
  }
}
function musicState ( e ) { stat = e . state ; if ( tPxt ) { clearTimeout ( tPxt ) ; tPxt = null ; } if ( tIxt ) { clearTimeout ( tIxt ) ; tIxt = null ; } fade = null ; if ( auto ) { switch ( stat ) { case "stop" : load ( ) ; break ; case "play" : tIxt = setTimeout ( load , ( e . dur * 2000 ) || IOUT ) ; break ; case "pause" : default : tPxt = setTimeout ( load , POUT ) ; fade = Date . now ( ) ; fadeOut ( ) ; break ; } } if ( BANGLE2 || Bangle . isLCDOn ( ) ) { drawControls ( ) ; } }
Update music state
 @param {Object} e - Gadgetbridge musicstate event
Update music state @param { Object } e - Gadgetbridge musicstate event
// if paused for five minutes, load the clock // (but timeout resets if we get new info, even while paused) // auto opened -> auto close // never actually happens with my phone :-( // if inactive for double song duration (or an hour if unknown), load the clock // i.e. phone finished playing without bothering to notify the watch // quit when paused for a long time // also fade out track info while waiting for this