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 does not allow to style the like button, so that's why I am asking about youtube player customization.
Asked
Active
Viewed 3.0k times
1 Answers
15
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
<div id="player"></div>
<button class="start-video">Start Video</button>
CSS
button {
position: absolute;
top: 106px;
padding: 12px;
left: 174px;
}
I've created a Jsfiddle with a working example.

AfromanJ
- 3,922
- 3
- 17
- 33
-
12This is not working, you can see the youtube button underneath your custom button in the fiddle. – roNn23 Oct 27 '15 at 13:28
-
Not for me @roNn23, in Chrome the linked fiddle from AfromanJ looks good and ist customizable. – Herr_Hansen Aug 23 '17 at 15:48