Fixed youtube video display

This commit is contained in:
Asutosh Palai
2016-07-04 07:44:44 -04:00
parent 2c582ca9c2
commit 5bc6cc62ec
3 changed files with 27 additions and 4 deletions

View File

@ -6,3 +6,23 @@ $(function() {
$(this).addClass(imgClass);
})
});
function onYouTubeIframeAPIReady() {
$('.youtube-video').each(function() {
var id = $(this).data('id');
var player = new YT.Player('youtube-video-' + id, {
events: {
'onStateChange': onPlayerStateChange
}
});
function onPlayerStateChange(event) {
if(event.data === YT.PlayerState.ENDED || event.data === YT.PlayerState.PAUSED)
$('#youtube-title-' + id).show();
else
$('#youtube-title-' + id).hide();
}
});
}