• <i id='5oyyX'><tr id='5oyyX'><dt id='5oyyX'><q id='5oyyX'><span id='5oyyX'><b id='5oyyX'><form id='5oyyX'><ins id='5oyyX'></ins><ul id='5oyyX'></ul><sub id='5oyyX'></sub></form><legend id='5oyyX'></legend><bdo id='5oyyX'><pre id='5oyyX'><center id='5oyyX'></center></pre></bdo></b><th id='5oyyX'></th></span></q></dt></tr></i><div id='5oyyX'><tfoot id='5oyyX'></tfoot><dl id='5oyyX'><fieldset id='5oyyX'></fieldset></dl></div>
      <bdo id='5oyyX'></bdo><ul id='5oyyX'></ul>
    <legend id='5oyyX'><style id='5oyyX'><dir id='5oyyX'><q id='5oyyX'></q></dir></style></legend>
  • <tfoot id='5oyyX'></tfoot>

    1. <small id='5oyyX'></small><noframes id='5oyyX'>

        Youtube iframe api 未触发 onYouTubeIframeAPIReady

        Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)

        <small id='dVJAr'></small><noframes id='dVJAr'>

          <tfoot id='dVJAr'></tfoot><legend id='dVJAr'><style id='dVJAr'><dir id='dVJAr'><q id='dVJAr'></q></dir></style></legend>
            <bdo id='dVJAr'></bdo><ul id='dVJAr'></ul>
            1. <i id='dVJAr'><tr id='dVJAr'><dt id='dVJAr'><q id='dVJAr'><span id='dVJAr'><b id='dVJAr'><form id='dVJAr'><ins id='dVJAr'></ins><ul id='dVJAr'></ul><sub id='dVJAr'></sub></form><legend id='dVJAr'></legend><bdo id='dVJAr'><pre id='dVJAr'><center id='dVJAr'></center></pre></bdo></b><th id='dVJAr'></th></span></q></dt></tr></i><div id='dVJAr'><tfoot id='dVJAr'></tfoot><dl id='dVJAr'><fieldset id='dVJAr'></fieldset></dl></div>
                <tbody id='dVJAr'></tbody>

                • 本文介绍了Youtube iframe api 未触发 onYouTubeIframeAPIReady的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经与 youtube iframe api 斗争了很长一段时间了.不知何故,方法 onYouTubeIframeAPIReady 并不总是被触发.

                  I've been battling with the youtube iframe api for quite some time now. Somehow the method onYouTubeIframeAPIReady is not always triggered.

                  从症状来看,似乎是加载问题.检查器中没有显示错误.

                  From the symptoms it seems a loading problem. No errors are shown in the inspector.

                  这是我的代码:

                  <div id="player"></div>
                            <script>
                              videoId = 'someVideoId';
                              var tag = document.createElement('script');
                              tag.src = "//www.youtube.com/iframe_api";
                              var firstScriptTag = document.getElementsByTagName('script')[0];
                              firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
                            </script>
                  

                  JS

                  (在页面末尾调用.我尝试将代码放在上面的脚本之后,结果是一样的.)

                  JS

                  (called at the end of the page. I tried to place the code right after the above script and the result was the same.)

                  var isReady = false
                    , player
                    , poster
                    , video;
                  
                  $(function () {
                  $('.js-play').click(function (e) {
                      e.preventDefault();
                      interval = setInterval(videoLoaded, 100);
                    });
                  });
                  function onYouTubeIframeAPIReady() {
                    console.log(videoId)
                    player = new YT.Player('player', {
                      height: '445',
                      width: '810',
                      videoId: videoId,
                      events: {
                        'onReady': onPlayerReady//,
                        //'onStateChange': onPlayerStateChange
                      }
                    });
                  }
                  
                  function onPlayerReady(event) {
                    isReady = true;
                    console.log("youtube says play")
                  }
                  
                  function videoLoaded (){
                    if (isReady) {
                        console.log("ready and play")
                        poster.hide();
                        video.show();
                  
                        $('body').trigger('fluidvideos');
                  
                        player.playVideo();
                        clearInterval(interval);
                    } 
                  }
                  

                  问题在于,有时 console.log 没有打印任何内容,也没有任何反应.

                  The problem is that sometimes nothing gets printed by the console.log and nothing happens.

                  在手机上,这种情况一直都在发生.有什么想法吗?

                  On mobile phones this happens all the time. Any ideas?

                  推荐答案

                  这不是超时问题,你应该不需要手动触发这个函数.

                  It is not a timeout issue, and you should not need to fire this function manually.

                  确保您的 onYouTubeIframeAPIReady 函数在全局级别可用,而不是嵌套(隐藏)在另一个函数中.

                  Make sure your onYouTubeIframeAPIReady function is available at the global level, not nested (hidden away) within another function.

                  这篇关于Youtube iframe api 未触发 onYouTubeIframeAPIReady的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)

                    <small id='7doFu'></small><noframes id='7doFu'>

                        <tbody id='7doFu'></tbody>

                          <tfoot id='7doFu'></tfoot>
                        1. <i id='7doFu'><tr id='7doFu'><dt id='7doFu'><q id='7doFu'><span id='7doFu'><b id='7doFu'><form id='7doFu'><ins id='7doFu'></ins><ul id='7doFu'></ul><sub id='7doFu'></sub></form><legend id='7doFu'></legend><bdo id='7doFu'><pre id='7doFu'><center id='7doFu'></center></pre></bdo></b><th id='7doFu'></th></span></q></dt></tr></i><div id='7doFu'><tfoot id='7doFu'></tfoot><dl id='7doFu'><fieldset id='7doFu'></fieldset></dl></div>
                          <legend id='7doFu'><style id='7doFu'><dir id='7doFu'><q id='7doFu'></q></dir></style></legend>
                            <bdo id='7doFu'></bdo><ul id='7doFu'></ul>