On/off button for all music in app

This forum contains topics that were moved from Get Satisfaction
billyboy5000
Posts: 0
Joined: Sun Dec 13, 2015 1:08 am

On/off button for all music in app

Post 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?

asid
Posts: 0
Joined: Sun Aug 09, 2015 8:01 pm

On/off button for all music in app

Post 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
}

billyboy5000
Posts: 0
Joined: Sun Dec 13, 2015 1:08 am

On/off button for all music in app

Post by billyboy5000 »

Thanks yes i think local storage variable would be the answer. Need to figure out the script then....

billyboy5000
Posts: 0
Joined: Sun Dec 13, 2015 1:08 am

On/off button for all music in app

Post 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

billyboy5000
Posts: 0
Joined: Sun Dec 13, 2015 1:08 am

On/off button for all music in app

Post by billyboy5000 »

Now I have a new issue with audio playback, if anyone can help see here: https://getsatisfaction.com/apperyio/...

Ethelbert
Posts: 1
Joined: Sat Nov 21, 2020 3:59 am

Re: On/off button for all music in app

Post by Ethelbert »

That is actually quite difficult for beginners like me.

samgannett
Posts: 1
Joined: Tue Dec 01, 2020 6:31 am

Re: On/off button for all music in app

Post by samgannett »

Use this code
var playMusic = localStorage.getItem('playMusic');
if (playMusic == "true") {
// do something
}

EnochBoniface
Posts: 1
Joined: Wed Mar 10, 2021 6:38 pm

Re: On/off button for all music in app

Post by EnochBoniface »

Set the default music mode on the device you are using.

PattiPage
Posts: 1
Joined: Sat May 22, 2021 5:03 am

Re: On/off button for all music in app

Post by PattiPage »

Thanks

Last edited by PattiPage on Mon Jun 07, 2021 4:28 am, edited 1 time in total.
sophia97
Posts: 1
Joined: Wed Sep 22, 2021 8:50 am

Re: On/off button for all music in app

Post by sophia97 »

I would recommend just turning audio off on the music player audio source

Post Reply