HTML5 Audio 在 iOS Safari 浏览器上的问题

HTML5 audio 标签在IOS上多个属性无法生效,声音无法播放

测试例子  html5 audio标签在ios  浏览器

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
	<audio id="ringtone" loop="loop" src="sounds/ringtone.wav"></audio>

</body>
</html>
<script>
	function audioAutoPlay(id){
		var audio = document.getElementById(id),  
		    play = function(){  
		        audio.play();  
		        document.removeEventListener("touchstart",play, false);  
		    };  
		audio.play();  
		document.addEventListener("WeixinJSBridgeReady", function () {  
		    play();  
		}, false);  
		document.addEventListener('YixinJSBridgeReady', function() {  
		    play();  
		}, false);  
		document.addEventListener("touchstart",play, false);  
	}
	audioAutoPlay('ringtone'); 
</script>

猜你喜欢

转载自blog.csdn.net/qq_22564293/article/details/79898008