Answers for "youtube iframe api get current time"

0

youtube iframe api get current time

var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

var player;
function onYouTubeIframeAPIReady() {
  player = new YT.Player('player', {
    videoId: 'M7lc1UVf-VE',
    events: {
      'onStateChange': onPlayerStateChange
    }
  });
}

function onPlayerStateChange(event) {
  console.log( player.playerInfo.currentTime );
}
Posted by: Guest on June-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language