Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<div class="video-embede" style="margin-left: auto;margin-right: auto;display: block; -webkit-box-shadow: 0 4px 10px -1px #C8C8C8; box-shadow: 0 4px 10px -1px #C8C8C8 !important;">
<div id="player">
</div>
</div>
 
      // 2. This code loads the IFrame Player API code asynchronously.
      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 section = {
  start: 30,
  end: 58
};
 
// 3. This function creates an <iframe> (and YouTube player)
//    after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
  player = new YT.Player(
    'player',
    {
      height: '0',
      width: '0',
      videoId: 'S5xDk7dnmbw',
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange
      }
    }
  );
}
 
function onPlayerReady(event) {
  player.seekTo(section.start);
  player.playVideo();
}
 
function onPlayerStateChange(event) {
  if (event.data == YT.PlayerState.PLAYING) {
    var duration = section.end - section.start;
    setTimeout(restartVideoSection, duration * 1000);
  }
}
 
function restartVideoSection() {
  player.seekTo(section.start);
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers