Set html audio play/pause based on a cookie (works only on pause, but not on play)

Solved, turns out I just needed to use

if(isMuted=='true')

and then isMuted = 'false'; or isMuted = 'true';

Here is the updated pen

Works like a clock in Chrome with autoplay enabled! :slight_smile:

Safari is more strict with the autoplay, so I added a check and only run this code for Chrome, and run standard player for Safari

var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

if(isSafari){ 
alert('Is safari');
//Do something

} else {
alert('Is other browser');
// Do something
}

If someone finds a workaround for autoplay in Safari, or if you need help with implementing it in Chrome please let me know!

1 Like