Background audio in Web page

I want to use a audio in background of a web page but after a web page changes the audio is restarted. I want it to play continuously whether web page changes or not without any interrupt.

1 answer

  • answered 2020-06-02 10:18 FedericoCozziVM

    I don't think you can actually do that as I think you want to do it. I assume you load and reproduce the audio in some .js file, which is run on page load by the browser; as you navigate i.e. in your website, the browser re-load all the source files (and also your audio).

    I think the best thing you can do is to re-project your page/website as a web-app. Doing that, when you navigate from a page to another you're not actually "leaving" the main page, but you're hiding/showing some html content: in this case, load the audio when the main page is loaded and it will continue to reproduce.

    Another, worse, thing you can do is to save the timestamp of the audio track in the current session when you leave the first page, and re-load the audio track from the saved timestamp in the next page. I think this is a worse option as your audio track will be paused till the next page content is loaded (and that could take time in case of connection issues and/or big media files)