Stopping embebed Youtube video does not work

Hello!

I followed the instructions about how to control an embebed Youtube video but I can not stop the video; the code is the next...Have anybody any idea please? Thanks!

var player;

if (element.id == "play"){

	player = new YT.Player('player', {
	  height: '100%',
	  width: '100%',
	  playerVars: {
	            autoplay: 1,
	            loop: 1,
	            controls: 0,
	            showinfo: 0,
	            autohide: 1,
	            modestbranding: 1,
	            vq: 'hd1080'},
	  videoId: 'aFu-NsGHqfI',
	  events: {
	    'onReady': onPlayerReady,
	    'onStateChange': true
	  }
	});
	
	function onPlayerReady(event) {
  		player.playVideo(); 
	}

 }else if ( element.id == "stop"){
 	player.stopVideo();
 }

player.hype.zip (15.0 KB)

very simplest solution: remove the var-declaration in the first line. just player or window.player

2 Likes

ok! thanks !