【问题标题】:How can I use the new (2016) Vimeo javascript API to start a video?如何使用新的 (2016) Vimeo javascript API 开始视频?
【发布时间】:2016-12-14 13:45:57
【问题描述】:

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

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

【问题讨论】:

  • 您链接的那个页面有示例和 api 文档。
  • @DanielA.White 是的,但它没有问题中要求的示例...... :)

标签: javascript vimeo vimeo-api vimeo-player


【解决方案1】:

要通过新的 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-10
    • 1970-01-01
    • 2011-07-30
    • 2013-11-17
    • 2019-11-24
    • 2018-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多