How To Get Video Play Paused Status With Vimeo Api?
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 Yo
Solution 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.
<iframeid="player_1"src="http://player.vimeo.com/video/7100569?api=1&player_id=player_1"width="540"height="304"frameborder="0"webkitallowfullscreen></iframe>
Solution 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
Solution 3:
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
Solution 4:
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 trueorfalse here
});
Solution 5:
var onPlay = function(data) {
console.log("play")
};
var onPause = function(data) {
console.log("pause")
};
player.addEvent('play', onPlay);
player.addEvent('pause', onPause);
Post a Comment for "How To Get Video Play Paused Status With Vimeo Api?"