jQuery .play() doesn't work on mobile Safari

只愿长相守 提交于 2019-12-12 03:27:40

问题


I'm using JQuery and I tried this code

<video id="videoPopUp1" poster="img/xxx.png">
       <source src="video/xxx.mp4" type="video/mp4">
</video>

$('#playBtn1').click(function () {
    $("#playBtn1").hide();
    $('#videoPopUp1').get(0).play();
});

$('#videoPopUp1').click(function () {
    if (this.paused == false) {
       this.pause();
       $('#playBtn1').show()
  } else {
       this.play();
       $('#playBtn1').hide()
    }
});

but on Iphone (Safari, iOS 9.3.1) and Ipad (Safari, 8.1.2) it doesn't work. It works fine on all other browsers/devices (Chrome, Firefox, android, etc.).


回答1:


That does not work because autoplay (and preloading) is disabled in safari on iOS.

In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled.

That means that you will always need "User Interaction" to start video playback.



来源:https://stackoverflow.com/questions/36739102/jquery-play-doesnt-work-on-mobile-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!