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.
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.
Share Improve this question asked Mar 3, 2016 at 23:57 zazvornikizazvorniki 3,60223 gold badges78 silver badges125 bronze badges 3- Have you tried anything yet? If so please edit your question and include your attempt(s). – NewToJS Commented Mar 4, 2016 at 0:08
- The Web Audio API might be a good place to start. – nathansnider Commented Mar 4, 2016 at 0:11
- @nathansnider, That's interesting I'll have to look at that. It seems a little too plex for what I'm trying to do here though. – zazvorniki Commented Mar 4, 2016 at 0:20
1 Answer
Reset to default 16You can use this:
mySound = new Audio('sound.mp3');
mySound.play()
Here is a link to its specification - HTMLAudioElement