Page 1 of 2
On/off button for all music in app
Posted: Thu Jan 21, 2016 8:16 am
by billyboy5000
I am building a children's app which have several different audio tracks depending on which page you are on, they auto play. I inserted them as html5 audio.
I created a mute button which can stop the audio. However, the problem i have is that when you navigate to a different page the music will start playing again.
What i need is some kind of mute button that will stop all audio in the app and for it to 'remember' the setting. Maybe a cookie or something i dont know the best solution, can anyone help and suggest?
On/off button for all music in app
Posted: Thu Jan 21, 2016 8:57 am
by asid
You can set a local storage variable and check the status on page load or show.
var playMusic = localStorage.getItem('canPlay');
if (playMusic == "true") {
// do something
}
On/off button for all music in app
Posted: Tue Jan 26, 2016 7:23 am
by billyboy5000
Thanks yes i think local storage variable would be the answer. Need to figure out the script then....
On/off button for all music in app
Posted: Wed Feb 03, 2016 6:33 am
by billyboy5000
Your code was missleading...
I had to use
var playMusic = localStorage.getItem('playMusic');
if (playMusic == "true") {
// do something
}
what was the canPlay part about?! took me ages to spot that
On/off button for all music in app
Posted: Wed Feb 03, 2016 9:06 am
by billyboy5000
Now I have a new issue with audio playback, if anyone can help see here: https://getsatisfaction.com/apperyio/...
Re: On/off button for all music in app
Posted: Sat Nov 21, 2020 4:02 am
by Ethelbert
That is actually quite difficult for beginners like me.
Re: On/off button for all music in app
Posted: Tue Dec 01, 2020 6:33 am
by samgannett
Use this code
var playMusic = localStorage.getItem('playMusic');
if (playMusic == "true") {
// do something
}
Re: On/off button for all music in app
Posted: Wed Apr 14, 2021 2:44 am
by EnochBoniface
Set the default music mode on the device you are using.
Re: On/off button for all music in app
Posted: Sat May 22, 2021 5:06 am
by PattiPage
Re: On/off button for all music in app
Posted: Wed Sep 22, 2021 8:51 am
by sophia97
I would recommend just turning audio off on the music player audio source