<audio> tags are a very meaningful feature of HTML5. Farewell to the flash of the era. Its properties are:
AutoPlay: Play immediately after audio is ready
CONTROLS: This property appears, displaying the playback controls to the user.
Loop: Whether to re-play at the end of the audio
Preload: If this property appears, it is loaded when the page loads.
src: The URL of the audio to play.
Methods are:
Load (): New load resource.
Play (): Start playback.
Pause (): pauses playback.
These are the basic points of knowledge. If we need to let the audio play automatically. In the iphone, we found that it was impossible to achieve .
Here the solution is on this page
document.addeventlistener (' Touchstart ',function(){
Document.queryselector ("#musicBox"). Play ()
}, true);
The ability to implement playback (meaning that it must be triggered manually).
If triggered automatically, the event mechanism has to be understood.
In the mouse event:
var Elem = document.getElementById (' pp '); Elem.addeventlistener (' click ', function () {Alert (111)}, True); var evt = document.createevent (' MouseEvent '); evt.initmouseevent (' Click ', True, true, window, 1, 12, 3 7, 0, False, False, true, FALSE, and NULL); Elem.dispatchevent (EVT);
In the same vein, in the Touch event:
varElem = document.getElementById (' pp ');
Elem.addeventlistener (' Touchstart ',function(){
Alert (111)
},true);
varEVT = document.createevent (' touchevent ');
Evt.inittouchevent (' click ',true,true, window, 1, 12, 345, 7, 220,false,false,true,false, 0,NULL);
elem.dispatchevent (evt);
Implement a function point similar to jquery's trigger
HTML5 's <audio> audio "pit"