OGeek|极客世界-中国程序员成长平台

标题: javascript - Vimeo 播放器 JS API 在 iOS 中不起作用 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:48
标题: javascript - Vimeo 播放器 JS API 在 iOS 中不起作用

我正在尝试使用 API 播放视频,但它仅在您单击 iOS 播放器中的播放按钮后才有效。在桌面和 Android 版 Chrome 中,它运行良好。

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>lay</button>
  <button>ause</button>
  <p>Status: <span class="status">&hellip;</span></p>
</div>

有没有我可以使用的解决方法?



Best Answer-推荐答案


我联系了 Vimeo 支持团队。他们说 Chrome Mobile (Android) 中的行为有所不同,因为他们能够在该浏览器 (Chrome Mobile) 中使用播放器。在 iOS 中,播放由 iOS 原生媒体播放器处理。

只有当用户首先通过点击屏幕上的播放按钮(在 iOS 中)开始播放时,才能调用它们的 Play 方法。

相关问题: Can you autoplay HTML5 videos on the iPad?

关于javascript - Vimeo 播放器 JS API 在 iOS 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35967342/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4