Disclaimer: iOS systems do not support FALSH, so HTML5 audio tags supported by each platform
<script>
Create an audio label
var audio = document.createelement ("audio");
Add Audio Property ID
Audio.id = "Audio";
Set the playback file path
AUDIO.SRC = "Sound/music.mp3";
Set whether to loop playback
Audio.loop = "loop";
Get current client environment information
var ua = Window.navigator.userAgent.toLowerCase ();
Determine the current environment and make appropriate processing
if (Ua.match (/iphone/i) = = "iphone" | | ua.match (/ipod/i) = = "ipod" | | ua.match (/ipad/i) = = "ipad") {
Currently an iOS-related environment, adding event Touchstart monitoring for a canvas node
document.getElementById ("Canvas"). AddEventListener ("Touchstart", function () {
Audio playback
Audio.play ();
});
}else if (ua.match (/android/i) = = "Android") {
Do not process the Android system
}else{
For non-iOS, Android systems, use the Listen Click event to
document.getElementById ("Canvas"). AddEventListener ("click", Function () {
Audio playback
Audio.play ();
});
}
</script>
This article is from the "Mirwangsir" blog, make sure to keep this source http://mirwangsir.blog.51cto.com/7723278/1565734
Use HTML5 tag audio to play audio with different clients