3

I have widgets running in an iBook. In particular, they play some music and sounds, as well as a Javascript "main loop".

I'd like sound and music to stop whenever the Widget is closed by the user. I don't know if there is some "FocusLost" or "WidgetClosed"-like event fired up by the iBook.

To my current understanding, this use case doesn't fire up "onunload", because this one would run whenever the iPhone decides to reclaim some memory because it needs it for the page the user is currently on.

What's the standard solution to this problem?

Kheldar
  • 5,361
  • 3
  • 34
  • 63

1 Answers1

1

I partially solved this using a combination of focusout and blur events, with tabindex=1 added to the widget html element.

Remaining problem is the absence of focusing if just doing a slide and closing.

Kheldar
  • 5,361
  • 3
  • 34
  • 63
  • I also discovered (much later) the pauseAudioVisual and didEnterWidgetMode possibilities offered by AppleClasses/AppleWidget.js, which is available on iPad through an import – Kheldar Jan 14 '13 at 16:47