• <legend id='ui5ab'><style id='ui5ab'><dir id='ui5ab'><q id='ui5ab'></q></dir></style></legend>
      <bdo id='ui5ab'></bdo><ul id='ui5ab'></ul>

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

    1. <small id='ui5ab'></small><noframes id='ui5ab'>

      1. <tfoot id='ui5ab'></tfoot>

        在播放 youtube iframe 嵌入时触发事件

        Fire an event on play of youtube iframe embed(在播放 youtube iframe 嵌入时触发事件)
        <legend id='FJhuc'><style id='FJhuc'><dir id='FJhuc'><q id='FJhuc'></q></dir></style></legend><tfoot id='FJhuc'></tfoot>
      2. <i id='FJhuc'><tr id='FJhuc'><dt id='FJhuc'><q id='FJhuc'><span id='FJhuc'><b id='FJhuc'><form id='FJhuc'><ins id='FJhuc'></ins><ul id='FJhuc'></ul><sub id='FJhuc'></sub></form><legend id='FJhuc'></legend><bdo id='FJhuc'><pre id='FJhuc'><center id='FJhuc'></center></pre></bdo></b><th id='FJhuc'></th></span></q></dt></tr></i><div id='FJhuc'><tfoot id='FJhuc'></tfoot><dl id='FJhuc'><fieldset id='FJhuc'></fieldset></dl></div>

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

              <bdo id='FJhuc'></bdo><ul id='FJhuc'></ul>

                <tbody id='FJhuc'></tbody>

                  本文介绍了在播放 youtube iframe 嵌入时触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要在播放 youtube iframe 时触发一个事件.因此,当按下播放按钮时,我需要调用一个函数来隐藏 span.module-strip

                  I need to fire an event on play of a youtube iframe. So when the play button is pressed I need to call a function to hide the span.module-strip

                  我已经尝试过了,但也许我走错了路?

                  I've tried this but maybe I'm going down the wrong path?

                  $("#home-latest-vid")[0].onplay = function() {
                      alert('hi');
                  };
                  

                  HTML:

                  <div class="module module-home-video">
                  
                      <span class="module-strip">Latest Product Video</span>
                  
                          <iframe id="video" src="http://www.youtube.com/embed/RWeFOe2Cs4k?hd=1&rel=0&autohide=1&showinfo=0&enablejsapi=1" frameborder="0" width="640" height="360"></iframe>
                  </div>
                  

                  推荐答案

                  • 演示:https://so.lucailosofi.com/fire-an-event-on-play-of-youtube-iframe-embed/

                  <script src="https://www.youtube.com/iframe_api"></script>
                  
                  <div class="module module-home-video">
                      <span class="module-strip">Latest Product Video</span>
                      <div id="video"></div>
                  </div>
                  
                  <script>
                      var player, playing = false;
                      function onYouTubeIframeAPIReady() {
                          player = new YT.Player('video', {
                              height: '360',
                              width: '640',
                              videoId: 'RWeFOe2Cs4k',
                              events: {
                                  'onStateChange': onPlayerStateChange
                              }
                          });
                      }
                  
                      function onPlayerStateChange(event) {
                  
                        if (event.data == YT.PlayerState.PLAYING) {
                           alert('video started');
                           playing = true;
                          }
                  
                        else if(event.data == YT.PlayerState.PAUSED){
                              alert('video paused');
                              playing = false;
                         }
                  }
                  </script>
                  

                  这篇关于在播放 youtube iframe 嵌入时触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                  How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)
                    <bdo id='IgXL2'></bdo><ul id='IgXL2'></ul>
                  • <small id='IgXL2'></small><noframes id='IgXL2'>

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

                          1. <legend id='IgXL2'><style id='IgXL2'><dir id='IgXL2'><q id='IgXL2'></q></dir></style></legend>