html5在 Android / IOS上不能自动播放音乐或视频

html5在 Android / IOS上不能自动播放


试了很多办法都不能让html5在手机上自动播放音乐或视频。在PC上是可以滴。据说是专门弄成这样地,目的是为了限制手机流量。

Audio/video autoplay is not allowed on iPhone, iPad and Android. It’s a limit from the device, and there is no way to bypass it.

试过的:

1.

<audio id="audio1" autobuffer autoplay loop >
                         <source src="../bell02.mp3" type="audio/mpeg" />
</audio>

2.

<embed mastersound name="sound1" src="../bell02.mp3" volume="100" hidden="true"    autostart="true">

3.

<html>

 <audio id="audio1" autobuffer autoplay loop >
      <source src="../bell02.mp3" type="audio/mpeg" />

</audio>
 <a href="#" id="play-button">play!</a>

<script>

var audio = document.getElementById('audio1');

var button = document.getElementById('play-button');

//- 按 play 出声:
button.addEventListener('click',function(){
      audio.play();
});

//--时间中断不出声:

setTimeout(function() { audio.play(); }, 2000 );

</script>
 
4.

<script>

var audio = new Audio('"../bell02.mp3');
audio.play();

</script>


-----全都不行(PC上可以)





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值