Is there a js callback when the YouTube player starts up again after a pause in the buffer?

I am trying to find out if there is a callback when the player no longer has .

I use onPlayerBuffering: function(){};right now when the player starts buffering, but I can not find anything that does the opposite.

onPlayerPlaying: function(){};doesn't seem to work after player buffers.

Does anyone know if this is possible?

In addition, I use the Nirvana Tikku jquery-youtube pluggin , a callback list here and here ... None of them will do the job?

THANK!!

+5
source share
2 answers

API- YouTube https://developers.google.com/youtube/js_api_reference#Events

onStateChange:

: http://jsbin.com/izolo/edit

:

function handlePlayerStateChange (state) {
  switch (state) {
    case 1:
    case 3:
      // Video has begun playing/buffering
      videoContainer.cycle('pause');
      break;
    case 2:
    case 0:
      // Video has been paused/ended
      videoContainer.cycle('resume');
      break;
  }
}

function onYouTubePlayerReady(id){
  var player = $('#' + id)[0];
  if (player.addEventListener) {
    player.addEventListener('onStateChange', 'handlePlayerStateChange');
  }
  else {
    player.attachEvent('onStateChange', 'handlePlayerStateChange');
  }
}
0

, , :

// set interval to something reasonable, 5 seconds?
var buffercheck = setInterval(bufferstatus, 5000);
function bufferstatus() {
  onPlayerBuffering: function(){ /* your code for a callback here */ },
}
0

All Articles