要通過新的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看看。
您鏈接的頁面有示例和api文檔。 –
@ DanielA.White是的,但它沒有在問題中要求的示例... :) – PetaspeedBeaver