问题
I was just wondering how I can detect if the video is playing or paused (or even loaded/ buffering) on the Vimeo API (http://player.vimeo.com/playground) it's a lot different to Youtube!
Joe
回答1:
Check the richest example of using vimeo Player Javascript API. It uses froogaloop library to communicate vimeo JS API. Don't forget to add id and parameters to the iframe element.
<iframe id="player_1" src="http://player.vimeo.com/video/7100569?api=1&player_id=player_1" width="540" height="304" frameborder="0" webkitallowfullscreen></iframe>
回答2:
The Vimeo Player JavaScript API provides the following method:
paused():Boolean
This return returns false if the video is playing, true otherwise.
Full details here: http://developer.vimeo.com/player/js-api
回答3:
Turns out you have to pass a callback as a second param to .api()
, which will receive true
/ false
based as the pause state of the player:
player.api('paused', function(paused) {
// paused will be true or false here
});
https://github.com/vimeo/player-api/issues/31
回答4:
Looks like their documenentation slightly changed since last answer. After you get the instance of the player you can check the playing/pause state by:
player.getPaused().then(function(paused) {
if(paused){
player.play();
}else{
player.pause();
}
});
From vimeo player api docs
回答5:
var onPlay = function(data) {
console.log("play")
};
var onPause = function(data) {
console.log("pause")
};
player.addEvent('play', onPlay);
player.addEvent('pause', onPause);
来源:https://stackoverflow.com/questions/15973698/how-to-get-video-play-paused-status-with-vimeo-api