javascript - Vimeo 播放器 JS API 在 iOS 中无法运行

标签 javascript ios mobile-safari vimeo-player vimeo-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>Play</button>
  <button>Pause</button>
  <p>Status: <span class="status">&hellip;</span></p>
</div>

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

最佳答案

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

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

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

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

相关文章:

javascript - Angular UI路由器和 Controller 继承中的 subview ?

javascript - 忽略机器人删除的消息

ios - 如何使 MasterDetailPage 图标 VoiceOver 易于访问?

iphone - Mobile Safari 和 HTML5 iOS 网络应用程序支持哪些音频文件类型(例如 mp3、ogg)?

javascript - ng-model 值中的 AngularJS 日期未传递给 Controller

javascript - 使用 Prometheus 监控 Angular 前端

ios - 在 UIView 上快速绘制 UIImage 图像

iphone - 我可以让 iphone 应用说话吗?

javascript - 为什么 Google Maps .getCenter() 返回无效坐标?

css - 在 Safari 中,Div 在 iPad 上崩溃