I’m trying to get something like an index page of a youtube video so that there are links to specific times of the video. I tried it to do like explained in Links to Specific Times in YouTube iframe embed, but somehow it doesnt seem to work. This is my code:
<script>
var tag = document.createElement('script');
tag.src = "//www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('video', { events: {'onReady': onPlayerReady}});
}
function playerSeekTo(seconds) {
player.seekTo(seconds);
}
</script>
HTML:
<iframe src="https://www.youtube.com/embed/FKWwdQu6_ok?enablejsapi=1" frameborder="0" allowfullscreen id="video">
</iframe>
<a href="#" onclick="playerSeekTo(70); return false;">Link to 1 minutes 10 seconds</a>
<a href="#" onclick="playerSeekTo(90); return false;">Link to 1 minutes 30seconds</a>
<a href="#" onclick="playerSeekTo(110); return false;">Link to 1 minutes 50 seconds</a>