※デベロッパーツール等でソースコードをご確認ください(Please check using Developer tools)
再生後10秒経過で表示するように設定中
.wrap {
width: 768px;
margin: 50px auto 0;
}
.text {
margin: 0 0 20px;
text-align: center;
}
#movie {
position: relative;
width: 100%;
padding-bottom: 56.25%;
}
#movie iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.movie_btn {
display: none;
width: 350px;
margin: 50px auto 0;
}
.movie_btn a {
display: block;
padding: 30px 0;
text-align:center;
font-weight: 700;
color: #fff;
background: #c00;
}
@media screen and (max-width:640px){
.wrap {
width: 100%;
}
}
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",{
events: {
'onStateChange': onPlayerStateChange
}
});
}
var check = false;
function onPlayerStateChange(event) {
setTimeout(ytTime, 100);
//ここで経過秒数を指定
var ytSeconds = 10;
function ytTime() {
if (!check) {
console.log(player.getCurrentTime());
if(ytSeconds < player.getCurrentTime()){
$('.movie_btn').fadeIn('slow');
check = true;
}else{
setTimeout(ytTime, 100);
}
}
}
}