shyguy Posted May 31 Share Posted May 31 Hi all - Im trying to get a PLAY button to work in my header. I tried following the instructions on these two forum pages and I was able to get the button to appear somewhat OK. But the music isn't playing! This is the code I have in my footer and this is the song I want to have play @tuanphan you seem to be incredibly helpful on these topics, your help would be greatly appreciated. Quote <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"/> <script> $(document).ready(function() { // audio icon $('<a id="play-pause-button" class="fa fa-play"></a>').appendTo('.header-actions--right .header-actions-action'); }); </script> <script> $(document).ready(() => { var audio = new Audio("https://soundcloud.com/sam-berg-66080982/m?si=c20884fc5a5e4f96bf583536393b491d&utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing"); audio.onended = function() { const list = document.querySelectorAll('#play-pause-button'); for (let i=0; i<list.length; i++) { $(list[i]).removeClass('fa-pause'); $(list[i]).addClass('fa-play'); } }; window.addEventListener('mousedown', (e) => { const btn = e.target if (btn.id === 'play-pause-button') { console.log(3534); if($(btn).hasClass('fa-play')) { $(btn).removeClass('fa-play'); $(btn).addClass('fa-pause'); audio.play(); } else { $(btn).removeClass('fa-pause'); $(btn).addClass('fa-play'); audio.pause(); } } }); }); </script> Link to comment
tuanphan Posted June 2 Share Posted June 2 If you share your site url, I can check easier. Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
shyguy Posted June 2 Author Share Posted June 2 Thanks! https://www.taliaanddavid.com/ or ferret-drum-7w99.squarespace.com Link to comment
shyguy Posted June 4 Author Share Posted June 4 hi @tuanphan any chance youre able to help here? greatly appreciated. thank you Link to comment
tuanphan Posted June 6 Share Posted June 6 I just solved a similar case yesterday, if you provide password, I will try adjust code for your site Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) 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