Plays a sound via HTML5 through Audio tags on the page - Node.js HTML

Node.js examples for HTML:Audio

Description

Plays a sound via HTML5 through Audio tags on the page

Demo Code

/**//  w w  w.j  a va 2  s.c o m
* Plays a sound via HTML5 through Audio tags on the page
*
* @require the id must be the id of an <audio> tag.
* @param id the id of the element to play
* @param loop the boolean flag to loop or not loop this sound
*/
startSound = function(id, loop) {
  soundHandle = document.getElementById(id);
  if(loop)
    soundHandle.setAttribute('loop', loop);
  soundHandle.play();
}

Related Tutorials