Transferred from: http://blog.csdn.net/u012246458/article/details/50618759
Audio play Music
[Java]View PlainCopy
- <audio id="audio" src="Images/openspeech.mp3" style= "opacity:0" preload= "Auto" controls loop hidden="true"/>
This code is: can do background music
Page load loading music but not playing
By calling this code:
[Java]View PlainCopy
- var Myauto = document.getElementById (' audio ');
- Myauto.play ();
Music playback.
Additional attribute explanations:
- Preload: If this property appears, the audio loads when the page loads and prepares to play. If you use "autoplay", the property is ignored.
- AutoPlay: If this property appears, the audio plays immediately when it is ready. Code: autoplay= "AutoPlay", can also be used: autoplay= "true"
- CONTROLS: If this property appears, the control is displayed to the user, such as the play button.
- Loop: If this property occurs, the playback starts again each time the audio ends.
- Hidden: Hide the Playback interface
HTML-HTML5 Audio Music auto play, cycle play, etc.