javascript – Vimeo播放器JS API在iOS中不起作用
作者:互联网
我正在尝试使用API播放视频,但只有在您点击iOS中的播放器中的播放按钮后它才有效.在台式机和Chrome for Android中,它运行良好.
http://codepen.io/bdougherty/pen/JgDfm
$(function() {
var iframe = $('#player1')[0];
var player = $f(iframe);
var status = $('.status');
// When the player is ready, add listeners for pause, finish, and playProgress
player.addEvent('ready', function() {
status.text('ready');
player.addEvent('pause', onPause);
player.addEvent('finish', onFinish);
player.addEvent('playProgress', onPlayProgress);
});
// Call the API when a button is pressed
$('button').bind('click', function() {
player.api($(this).text().toLowerCase());
});
function onPause() {
status.text('paused');
}
function onFinish() {
status.text('finished');
}
function onPlayProgress(data) {
status.text(data.seconds + 's played');
}
});
<script src="https://f.vimeocdn.com/js/froogaloop2.min.js"></script>
<iframe id="player1" src="https://player.vimeo.com/video/76979871?api=1&player_id=player1" width="630" height="354" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<div>
<button>Play</button>
<button>Pause</button>
<p>Status: <span class="status">…</span></p>
</div>
我有可以使用的解决方法吗?
解决方法:
我联系了Vimeo支持团队.他们表示,Chrome Mobile(Android)的行为有所不同,因为他们可以在该浏览器(Chrome Mobile)中使用播放器.在iOS中,播放由iOS本地媒体播放器处理.
只有当用户通过点击屏幕上的播放按钮(在iOS中)首先启动播放时,才能调用Play方法.
相关问题:
Can you autoplay HTML5 videos on the iPad?
标签:javascript,ios,mobile-safari,vimeo-player,vimeo-ios 来源: https://codeday.me/bug/20191009/1876727.html