Random Auto-Play Audio with Caption + Cookie

This demo will load a random song every time the page is refreshed. The song title is displayed in the caption box and a toggle switch stops and starts playback. A cookie remembers when sound is manually turned off so that it won't auto-play again on return visits. Stop auto-play altogether by following instructions in the JS.

Works in modern browsers and IE9+

Note: Auto-play is disabled in iOS to preserve mobile data packages.

Please view the source of this page for HTML markup, CSS and JS. The relevant PHP is provided below.