2016-12-14 67 views
0

Vimeo有new (2016) javascript API。我正在尋找一個基本示例它正在使用到開始和停止一個視頻的JavaScript點擊頁面上的東西如何使用新的(2016)Vimeo JavaScript API來啓動視頻?

我發現,這兩項條款涵蓋的主題,但都是對舊frogaloop API:

+1

您鏈接的頁面有示例和api文檔。 –

+0

@ DanielA.White是的,但它沒有在問題中要求的示例... :) – PetaspeedBeaver

回答

0

要通過新的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> 
 
\t \t 
 
<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看看。