html - javascript Audio object vs. HTML5 Audio tag - Stack Overflow
HTML audio tag issues
List of V3 audio tags.
Is there a Universal or offical way(s) to tag your music correctly ?
Videos
According to this wiki entry at Mozilla <audio> and new Audio() should be the same but it doesn't look like that is the case in practice. Whenever I need to create an audio object in JavaScript I actually just create an <audio> element like this:
var audio = document.createElement('audio');
That actually creates an audio element that you can use exactly like an <audio> element that was declared in the page's HTML.
To recreate your example with this technique you'd do this:
var audio = document.createElement('audio');
audio.src = 'alarm.mp3'
audio.play();
JavaScript halts during an Alert or Confirm box.
You cannot concurrently run code and display an alert(), confirm(), or prompt(), it literally waits for user input on this, this is a core feature of JavaScript.
I am assuming it is that very reason why an audio file played entirely within JavaScript scope does this. Comparatively Flash video clips or HTML5 audio/video will continue to play on even when a JavaScript alert/confirm/prompt is open.
As for what method is better, well that is up to you. It is pretty archaic to do anything with the JavaScript built in alert/confirm/prompt anymore, there are way better looking prompts you can make with jQuery UI and so on.
If you have a lot of dynamic content on the page or are you looking into background buffering audio before they need to be triggered and so on, then JavaScript is probably the saner way to go about things.
If you have literally just one player on the screen then there is no excuse for not putting in onto the HTML code. Although unlikely to affect anyone these days, it is still bad practice to rely heavily on JavaScript when there is no reason to.
Is your wrongbuzzer.mp3 file saved in the same directory as your HTML file? If so, try running it on a different browser and if that still does not work, change the type to "audio/mp3".
First, you need to delete the extra space between src and =
Is the audio file located in the root of your site / project where you also have this html file? If not you need to add the correct path inside the src="".
I'm looking around for a list of audio tags for Eleven Labs. I found a few listed on their blog post on tags:
-
Emotional tone: [EXCITED], [NERVOUS], [FRUSTRATED], [TIRED]
-
Reactions: [GASP], [SIGH], [LAUGHS], [GULPS]
-
Volume & energy: [WHISPERING], [SHOUTING], [QUIETLY], [LOUDLY]
-
Pacing & rhythm: [PAUSES], [STAMMERS], [RUSHED]
Are there specific tags that work or is this just a matter of getting creative and coming up with any tag you want?
It would be nice to start compiling a list of tags.