It seems that with the current Youtube API you have to do more than just add enablejsapi
as a get parameter to the embed. You actually have to include the API script from here and also use the custom methods. You can take a look at the below code or run this working JSFiddle:
<iframe id="music" width="310" height="310" src="https://www.youtube.com/embed/v_FucrYWy3k?rel=1&controls=1&showinfo=0&start=1&autoplay=1&enablejsapi=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<button id='button' type="button" name="button">mute</button>
And the JS code:
//create the script for the API and append it to the DOM
var tag = document.createElement('script');
tag.src = 'https://www.youtube.com/iframe_api';
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('music', {
events: {
'onReady': onPlayerReady
}
});
}
function onPlayerReady(event) {
document.getElementById('button').addEventListener('click', function() {
player.pauseVideo();
})
}
It's all in the docs here.