在audio标签中,如果将这个放在普通的移动端,ios、安卓都是可以正常播放的,
在微信端,安卓播放正常,而ios端音频类无法正常播放( dom.play() ),这就需要用到微信的播放
第一步:引入微信官方 jweixin插件
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
第二步:
var audio = document.getElementById('dadishumusic'); //获取到audio对象
audio.play(); //尝试进行正常事件播放,在非微信端页面有效
wx.config({
debug : false, // 这里为false
appId : 'xxx', // 这里的appid 是必填的,可以到官网看源代码得到一个appid
// 以下随意填写即可
timestamp : (new Date()).getTime(),
nonceStr : '',
signature : '',
jsApiList : ['checkJsApi']
});
wx.ready(function() {
audio.play();
});