Am I allowed to replace the original youtube play icon on embedded youtube videos? I would place my own icon above the youtube iframe to achieve that. I know that facebook d
I'm not sure you can customise a YouTube embedded without using the YouTube JavaScript api.
Heres how to do it with the api:
Javascript
//youtube script
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
onYouTubeIframeAPIReady = function () {
player = new YT.Player('player', {
height: '244',
width: '434',
videoId: 'AkyQgpqRyBY', // youtube video id
playerVars: {
'autoplay': 0,
'rel': 0,
'showinfo': 0
},
events: {
'onStateChange': onPlayerStateChange
}
});
}
onPlayerStateChange = function (event) {
if (event.data == YT.PlayerState.ENDED) {
$('.start-video').fadeIn('normal');
}
}
$(document).on('click', '.start-video', function () {
$(this).fadeOut('normal');
player.playVideo();
});
HTML
CSS
button {
position: absolute;
top: 106px;
padding: 12px;
left: 174px;
}
I've created a Jsfiddle with a working example.