gpt4 book ai didi

javascript - 如何使用新的 (2016) Vimeo javascript API 开始播放视频?

转载 作者:行者123 更新时间:2023-11-29 19:08:10 30 4
gpt4 key购买 nike

Vimeo 有一个 new (2016) javascript API .我正在寻找一个基本示例,用于在单击页面上的某些内容时通过 javascript 启动和停止视频

我发现那两篇文章涵盖了这些主题,但都是关于旧的 frogaloop api 的:

最佳答案

要通过新的 javascript API 启动 Vimeo 视频,您只需在页面中包含该 API,然后执行 play 方法。请参见下面的示例:

<!-- Load the video iframe. Be sure to not forget to enable the api (api=1) -->
<iframe src="https://player.vimeo.com/video/87982573?api=1" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

<!-- When clicking this text the video will start -->
<p id='start'>click to start</p>

<!-- Including jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Including Vimeo player javascript API -->
<script src="https://player.vimeo.com/api/player.js"></script>

<script>
var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);
// Execute the `play` method of the API when something with id start is clicked
$('#start').click( function() {
player.play();
});
</script>

一定要看看Vimeos example page for the new player API .

关于javascript - 如何使用新的 (2016) Vimeo javascript API 开始播放视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41144200/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com