If I have an interactive widget that has something like
window.init = function() {alert('foo');};
or
<audio src="foo.mp3" autoplay="" loop=""></audio>
then when I close the interactive widget and bring it back up again, the init() doesn't run again and the audio won't automatically play.
In the case of audio, the sounds stops playing when you close the interactive widget. When you reopen the interactive widget, the sound does not start playing automatically.
However, if I page left or right a few pages (until I see the "loading..." indicator), then the interactive widget cache gets flushed. I can then go back to the page with the interactive widget and the init() will run and audio will play again.
(Note that for <audio>
to have a sound play automatically and loop, the autoplay
and loop
properties just have to exist. The value of those properties doesn't matter so I can just have quote quote)
Is this a known problem with ibooks?
Is there any way to force that cache flush?
You could try setting a function on
widget.didEnterWidgetMode
(more documentation here) that resets the progress when the widget gets opened again.edit: So if you look at this Apple thread on widget creation for iBooks Author, they mention adding a Javascript snippet for
AppleClasses/AppleWidget.js
. The code for that file is here (at least, according to someone on the internet :)), and in that file there's the samewidget.didEnterWidgetMode
function.