NazariyM
11/21/2016 - 3:42 PM

Video from Youtube

<div class="install__video">
    <iframe width="868" height="488" src="https://www.youtube.com/embed/CW5oGRx9CLM?enablejsapi=1" frameborder="0" allowfullscreen></iframe>
    <img class="install__pic" src="img/content/install-video.jpg" alt="Video">
    <div class="install__video-btn js-init-video"></div>
</div>

(function() {

	var yt_frame = document.querySelector('iframe'),
			video_placeholder = $('.js-init-video'),
			speed = 400;

	video_placeholder.on('click', function(e) {
			e.preventDefault();
			var _this = $(this);

			_this.siblings('iframe').slideDown(speed, function() {
					play();
			});
			setTimeout(function() {
					_this.fadeOut(speed).siblings('img').fadeOut(speed);
			}, speed / 5);

	});

	function play() {
			yt_frame.contentWindow.postMessage(JSON.stringify({
					'event': 'command',
					'func': 'playVideo',
					'args': []
			}), '*');
	}
		})();