JavaScript - How can I code Javascript to play audio continuously from page to page in iBooks.

Asked By Davey Coder on 11-Jun-14 01:50 AM
Hi,
 
I am trying to code a button in iBooks, where the user can touch the button, in order for music to play continuesly throught the book, even when a page is turned.
 
I have used the following so far:
 

    <div id="audioButton" class="ibooks-media-audio" data-ibooks-audio-reset-on-play="true"
    data-ibooks-audio-src="audio/background_audio.m4a"></div>

 
This uses iBooks.js
 
The problem is that this only works on a single page. As soon as the user turns to the next page, the audio stops.
 
Is there a way to make the audio keep playing when the page is turned. Some kind of global function, which can be controlled from any page.
 
I have switched off the background option, native in iBooks, as the Title: Read Aloud is present, which would missleed the user into thinking that
 
the book is a read aloud book.
 
This book is currently just images and background music.
Robbe Morris replied to Davey Coder on 11-Jun-14 10:03 AM
No, that's not how browser apps work.  http is a disconnected protocol.  Each new page request is independent of the next.  You could put something in the querystring to restart the player on the next page but I'm sure that isn't what you want.

You could accomplish this with frames though.  Create a one pixel high frame that contains your player.  Create a second frame that holds your content.  You can use JavaScript to trigger the player in the other frame.  When a user navigates your pages in the parent frame, the player frame will stay put and not reload.