How can I start playing music by clicking on widget?

Hello, in my graduation work I need to turn on music by clicking on the widget.

I tried to write the code, but it didn’t work out, I’m upset. Is it even possible?

I could leave you a small donation for your help…

HI @_442002 I would suggest sharing the code you have! But here i’ve attached an example.


<script src="https://code.jquery.com/jquery-3.6.1.js"></script>

<script>
var audioNAMEHERE = document.createElement('audio');
audioNAMEHERE.setAttribute('src', 'YOUR-AUDIO-URL-HERE');
audioNAMEHERE.addEventListener("load", function() {
  audioNAMEHERE.play();
}, true);

$('[READYMAG DATA ID HERE]').click(function() {
  audioNAMEHERE.play();
});
</script>
2 Likes

Hello, thank you SO much for the answer, I just saw it now. I don’t understand your code well, but I did everything as indicated in your comments: I added a link to the sound and found the ID of my standard shape‐widget readymag, BUT nothing worked for me. nothing happens by click, please poke me in my the error. Thank you dear!

thank you very much, I got everything, I had to replace the numbers with words

Hi, I’m struggling with the same issue. Don’t really know much about code, so I also can’t seem to figure it out myself. What am I supposed to fill in at the “audioNAMEHERE” parts of the code? If I fill in the name of my audio file that’s in dropbox it won’t work. Please let mr know! Thanks

simply change “audioNAMEHERE” to “GARDEN”

i also tried to implement the code and failed;

could you tell me where is the problem? the pic is not clickable.
i tried to put the code into every tab (head, before/after body, css) but it didnt work at all.
i would be super grateful for your answer!

Hey HEADLESS.HORSE your code is awesome and works like charm. It wil be awesome if you point us to to some code that will pause the audio as well. Thanks a lot!

1 Like

Hey David. Did you find out how to pause the audio?

maybe, because your src url isnt directly an mp3 file? it ends with “sharing” not with .mp3.

You can set up a pause if you use the same “…click(function() (…” listener and then just do “AUDIO.pause();”

1 Like