这段播放mp3的代码在iPad和iPhone中不能自动播放,需要点一下才能播放,在PC的各种浏览器上都没这个问题,请赐教。<script type="text/javascript">
function PlayBGMP3(mp3Path)
{
if (window.ActiveXObject || navigator.userAgent.indexOf("Opera")>=0)  //IE or Opera
{
document.write("<embed type='audio/mpeg' src='" + mp3Path + "' autostart='true' width='300' height='43' loop='true' volume='30' />");
}
else if (navigator.userAgent.indexOf("Firefox")>=0 || navigator.userAgent.indexOf("Safari")>=0 && navigator.userAgent.indexOf("Chrome")<0)  //Firefox or Safari
{
document.write("<object data='" + mp3Path + "' type='application/x-mplayer2' width='300' height='43'>");
document.write("<param name='src' value='" + mp3Path + "'>");
document.write("<param name='autostart' value='1'>");
document.write("<param name='playcount' value='infinite'>");
document.write("</object>");
}
else  //HTML5
{
document.write("<audio src='" + mp3Path + "' controls='controls' autoplay='autoplay' loop='loop'></audio>");
}
}
</script>