Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing audio without audio tag

Is it possible to play audio without the audio tag and just using javascript?

I'm injecting script through a tinyMce editor since I don't have access to a site's backend and it doesn't support the audio tag for a client. She just wants a simple sound when you hover over an image. I have it all setup however, the restriction of not having an audio tag is tripping me up.

I am hosting the audio files on a remote site since I cannot upload them here. Is there perhaps a way to leverage that remote site? I've never run into this issue before and can't really find anything on it.

like image 611
zazvorniki Avatar asked Mar 03 '16 23:03

zazvorniki


1 Answers

You can use this:

mySound = new Audio('sound.mp3');
mySound.play()

Here is a link to its specification - HTMLAudioElement

like image 117
Eni Arinde Avatar answered Oct 08 '22 21:10

Eni Arinde