You're confusing two different player APIs here.
Do you want to use the iframe player? If so, you'll want to look at: https://developers.google.com/youtube/iframe_api_reference.
Instead of defining onYouTubePlayerReady
, you'll want to define the following method: onYouTubeIframeAPIReady
, create your player, and then assign an onPlayerReady
callback.
Make sure you're including the JavaScript for the iframe player API, in order for onYouTubeIframeAPIReady
to be called:
var tag = document.createElement('script');
tag.src = o.protocol + "://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
Worth noting from the doc, since you're writing the iframe instead of using JavaScript to do that for you:
If you do write the tag, then when you construct the
YT.Player object, you do not need to specify values for the width and
height, which are specified as attributes of the tag, or the
videoId and player parameters, which are are specified in the src URL.
Also, in your mutePlayPauseUnmute function..
playerid.mute();
playerid.playVideo();
playerid.pauseVideo();
playerid.unMute();
You'll want to trigger the actual the methods on the player
as opposed to the playerid
as described above.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…