user7350434
user7350434

Reputation: 27

Keep playing audio when changing page

I'm using to play music on my home page, but when i change the page to player stops.

Is there a solution to keep the player running even if we go to another page ?

Upvotes: 1

Views: 3390

Answers (2)

Anime no Sekai
Anime no Sekai

Reputation: 190

You can create a single page and dynamically change the elements on the page (or for example create a container element which will have the page content).

You can change the URL of the page using pushState.

More on pushState: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState

The code is very messy for now but that's what I did for one of my projects: https://github.com/Animenosekai/Project_Erina/blob/master/ErinaServer/Erina/static/scripts/main.js#L62

Upvotes: 0

Supratim Samantray
Supratim Samantray

Reputation: 136

Show Page content in iframe. Keep music player alive in the main page. When you want to change the page, change the content of the iframe. Use pushstate to change the URL of browser without reloading the page. Thats what music site like saavn.com do.

Upvotes: 2

Related Questions