Autoplay video in PhoneGap

丶灬走出姿态 提交于 2019-12-20 05:18:09

问题


I have created a minimal PhoneGap app that has just this in the index.html:

<!-- ... -->
<body>
  <video src="test.m4v" autoplay onerror="alert('Error')"></video>
</body>

In the PhoneGap.plist I have set MediaPlaybackRequiresUserAction to NO.

Yet I still cannot get the video to autoplay when the page loads. I have tried different ways of scripting it but to no avail.

Does anybody have a clue what I'm doing wrong?


回答1:


Solved it. Turned out to be a bug in PhoneGap 1.3 which was fixed in version 1.4 released yesterday(!).

From the release notes:

Fixed CB-42 – MediaPlaybackRequiresUserAction can now be set to NO




回答2:


AutoPlay attribute work in ios :

  <video src="test.m4v" autoplay="autoplay"></video>

Given this line autoplay function




回答3:


"autoplay" attribute will not work in iOS so you need to use JavaScript to get it to play.

Here is some sample code:

var video = document.getElementById('someVideoId');
video.play();


来源:https://stackoverflow.com/questions/9078098/autoplay-video-in-phonegap

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