<script src='https://www.youtube.com/iframe_api'></script>
<script>
function convert(input) {
const afterStr = input.split(':');
let hour = 0;
let minutes = 0;
let seconds = 0;
if (afterStr.length == 3) { //시:분:초 일때
console.log("convert -> afterStr", afterStr);
hour = +afterStr[0]; //시
minutes = +afterStr[1]; //분
seconds = +afterStr[2]; //초
console.log("convert -> afterStr[2]", afterStr[2])
} else { //분:초 일때
minutes = +afterStr[0]; //시
seconds = +afterStr[1]; //분
}
const result = hour * 3600 + minutes * 60 + seconds;
return result;
}
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player("myplayer", {
width: 360,
height: 180,
videoId: '<?php echo $view['wr_1']?>',
});
}
$(function () {
$(".seekTo").click(function () {
const seektime = $(this).html();
const seekto_s = convert(seektime);
player.seekTo(seekto_s);
})
})
</script>