简体   繁体   中英

Custom html5 audio player

I found out that there is a new HTML5 tag. I want a HTML/Javascript code but I dont want any jQuery in it. Its for a html doc which will have music playing automaticaly in the background, i would like the code to make a little mute button in the topleft corner of the screen. Heres the standard code to work on.

<audio controls="?"* loop="loop">
  <source src="horse.wav" type="audio/wave">
</audio>

*: Not sure if to be included

The button may be text or picture and it may change (eg: mute/unmute or mute then when clicked changes to unmute and back).

This should work :

document.getElementById('background_audio').muted = true;

Demo: http://jsfiddle.net/mattball/sVwXH/ (no jQuery)

Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM