How to skip ad after 5 seconds using YouTube JS API?

I can do almost anything using the JavaScript API to take control of the YouTube Player.

player = document.getElementById('movie_player');

      

But I cannot find any feature that allows me to skip the promotional video (if any) after 5 seconds.

How can I achieve this?

+3


source to share


1 answer


You just need to define the id of the skip button (if any). Then call the event by clicking on it. Something looks like this:



setTimeout(function(){
  var _skip = $('#skip_button_id');
  if(_skip!=null)
    _skip.click();
}, 1000);
      

Run code


This is not real code. Just let me know how to do it.

0


source







All Articles