直到大约两周前,我才发现一切都很正常。我没有修改任何代码。
function loadYtVideo(video, advert, advert_link, splash, splash_link){
var params = { allowScriptAccess: "always", wmode: "transparent" };
var atts = { id: "eda-player", wmode: "transparent" };
var swfobject;
adv.orig = video;
swfobject.embedSWF("https://www.youtube.com/v/"+adv.orig+"?rel=0&enablejsapi=1&playerapiid=ytplayer","ytapiplayer", "719", "404", "8", null, null, params, atts);
}
function onYouTubePlayerReady(playerId) {
//It's fired
edaplayer = document.getElementById('eda-player');
edaplayer.addEventListener("onStateChange", "playerState");
}
function playerState(state) {
//it's not fired
console.log(state);
}
<div class="adv-video">
<div id="ytapiplayer">
<script>
$(document).ready(function(){
loadYtVideo($.getUrlVar('ytVideo'), 'eM2ja9LE0YE', 'http://wilmax.ru/', '', '');
});
</script>
</div>
</div>
我发现有类似问题的帖子,但这些帖子中的解决方案在这种情况下不起作用。任何帮助都将不胜感激。
发布于 2016-09-29 23:34:45
我建议你搬到YouTube IFrame Player API
IFrame播放器API允许您在您的网站上嵌入YouTube视频播放器,并使用JavaScript控制播放器。与Flash和JavaScript player API不同,IFrame API将内容发布到页面上的Flash。这种方法提供了比以前可用的API更多的灵活性,因为它允许YouTube为不支持HTML5的移动设备提供Flash播放器而不是Flash player。
Flash API和JS API已被弃用。我不确定它是否仍然适用于当前的API,这就是为什么我建议您使用Iframe API
以下是一些可能对您有帮助的资源:
希望这能有所帮助!
https://stackoverflow.com/questions/39742832
复制相似问题