vimeo 视频停止播放时触发事件? [英] Fire event when vimeo video stops playing?

查看:30
本文介绍了vimeo 视频停止播放时触发事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否可以在 vimeo 视频播放完毕后触发事件?

I was just wondering if it was possible to fire an event once a vimeo video has finished playing?

目前我有一个嵌入在叠加层中的 Vimeo,我想在视频停止后将其删除.希望这是有道理的!

Currently I have a Vimeo embed in an overlay, that I want to remove once the video has stopped. Hope this makes sense!

我真的没有任何有用的代码,但想知道您是否可以向视频添加事件侦听器,在视频完成后触发一个事件,以及您将如何执行此操作?

I dont really have any code that would be of use, but would like to know if you can add event listeners to the video, fire an event once the video has finished, and how you would go about doing this?

谢谢瑞恩

推荐答案

自从 Vimeo 推出新的 视频播放器 API.

Previous answer is now obsolete since Vimeo launching the new Video Player API.

重要提示:请务必从 iframe 的 URL 中删除?api=1.以前在使用 Froogaloop 库时需要这样做,现在不再需要了.如果您将其保留,则 'ended'、'seeked' 和其他事件将永远不会触发.

Important: Be sure to remove the ?api=1 from the URL in your iframe. This was previously required when using the Froogaloop library and is no longer needed. If you leave it in, the 'ended', 'seeked' and other events will never fire.

包括新脚本:

<script src="https://player.vimeo.com/api/player.js"></script>

然后使用以下示例:

$(document).ready(function(){

    var iframe = $('#container iframe');
    var player = new Vimeo.Player(iframe);

    player.on('ended', function() {
        console.log('Finished.');
    });

});

这篇关于vimeo 视频停止播放时触发事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆