IanHost Posted July 15, 2021 Share Posted July 15, 2021 (edited) Hey guys, this code I have found/put together from what i know, but when previewing in mobile, my hidden audio block doesn't autoplay. Can anyone help please? <script> window.addEventListener('DOMContentLoaded', function() { //wait for document load var audio = document.querySelector('.sqs-audio-embed'); //select the audio block var checkOnLoad = function() { if (window.pageYOffset > 200) { } else { audio.play(); } {audio.loop = true;} }; if (audio) { var url = audio.getAttribute('data-url'); //get the audio src Y.one(audio).ancestor('.sqs-block-audio').setStyle('display','none'); audio = new Audio(url); window.addEventListener('load', checkOnLoad); //listen for window load and toggle audio state checkOnLoad(); } }) </script> Edited July 15, 2021 by IanHost added tags Link to comment
tuanphan Posted July 16, 2021 Share Posted July 16, 2021 Hi. Can you share link to page where you use audio? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
IanHost Posted July 29, 2021 Author Share Posted July 29, 2021 Hey, I have sorted it all now thankyou Link to comment
sanfranciscosasha Posted November 16, 2022 Share Posted November 16, 2022 On 7/29/2021 at 6:59 AM, IanHost said: Hey, I have sorted it all now thankyou Hi, do you mind sharing your solution, i am also trying to figure out how to autoplay squarespace audio block thank you Link to comment
sanfranciscosasha Posted March 10 Share Posted March 10 Tuan and Ian, i'm having the same problem, and using the same code as Ian. My audio autoplays in chrome while i am in my editing mode, but no in safari or mobile. Here is the website, would appreciate some help on how you were able to solve it. https://bell-now.squarespace.com password ---- > demo Link to comment
tuanphan Posted March 12 Share Posted March 12 On 3/10/2023 at 11:03 AM, sanfranciscosasha said: Tuan and Ian, i'm having the same problem, and using the same code as Ian. My audio autoplays in chrome while i am in my editing mode, but no in safari or mobile. Here is the website, would appreciate some help on how you were able to solve it. https://bell-now.squarespace.com password ---- > demo You can consider this approach, I use another code Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care 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