I worked on something very similar, and I decided to go with a custom player using the iframe api https://developers.google.com/youtube/iframe_api_reference and remove the default chrome, which keeps them from skipping ahead.
// api has been loaded function onYouTubeIframeAPIReady(){ var player = new YT.Player(el, { videoId: video_id, width: 700, playerVars: { controls: 0, modestbranding: 1, rel: 0 }, events: { onStateChange: function(d){ switch(d.data){ case YT.PlayerState.ENDED: // send notification of video ended } } } }); } // async load of api var tag = document.createElement('script'); tag.src = "//www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
The function is called when the youtube api is fully loaded and configures the iframe player. el
is the dom object that you want to replace the video, and video_id
is the identifier of the video you want to download. controls: 0
- the magic bit that hides the playerβs chrome. Then in the onStateChange
function you can send an ajax request or change the layout or something else that you need to do at the end of the video.
source share