klc01 Posted October 31, 2022 Share Posted October 31, 2022 I'm using the Lightbox Anything plugin from Sqsp Themes to play a collection of audio files. My issue is on mobile. I. using a script found in the Forum to allowed the audio file to play in the same page on mobile, but when I close the lightbox, the audio continues to play. Desktop is fine. Site: whalingcommonground-cms.squarespace.com/stories-from-the-collection Pass: nbwm2022 This is the thread where I found the audio code, followed by the specific code I'm using. There are two other codes offered within this thread, but they also result in the audio continuing to play. Can anyone provide some assistance to end the audio when the lightbox is closed? Thank you! Link to comment
klc01 Posted November 2, 2022 Author Share Posted November 2, 2022 The developer shared this fix and I'm posting here in case anyone finds it helpful. Instructions were to place this before the plugin code. 🙂 <script>function lightboxStopAudioPlayer() {const button = document.querySelector('.c-lightbox__close');const stage = document.querySelector('.c-lightbox__stage');function pause() {const pauseButton = document.querySelector('.c-lightbox .pause-button');if (pauseButton) pauseButton.click();}button.addEventListener('click',pause);stage.addEventListener('click',pause);}</script><div data-lightbox-code-injection><script>setTimeout(lightboxStopAudioPlayer, 1000)</script></div> tuanphan and ufotofu 2 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment