• <bdo id='9qShq'></bdo><ul id='9qShq'></ul>

    <small id='9qShq'></small><noframes id='9qShq'>

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

        <legend id='9qShq'><style id='9qShq'><dir id='9qShq'><q id='9qShq'></q></dir></style></legend>

        Youtube 嵌入式视频开始/停止事件

        Youtube embedded video start / stop event(Youtube 嵌入式视频开始/停止事件)
        <legend id='UtI0c'><style id='UtI0c'><dir id='UtI0c'><q id='UtI0c'></q></dir></style></legend>

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

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

                  <tfoot id='UtI0c'></tfoot>
                    <tbody id='UtI0c'></tbody>

                1. 本文介绍了Youtube 嵌入式视频开始/停止事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道,通过 iframe 嵌入 youtube 视频是否会暴露某些事件,例如 onStart 或 onStop,您可以在其中指定一些回调?

                  I was wondering, does embedding a youtube video via iframe expose certain events, like onStart or onStop, where you can specify some callback?

                  推荐答案

                  这是一个处理启动和停止事件的例子:

                  This an example to handle start and stop events:

                  HTML 文件(index.html):

                  HTML file (index.html):

                  <!DOCTYPE html>
                  <html>
                      <head>
                          <title>Stackoverflow</title>
                          <script type="text/javascript" src="http://www.youtube.com/player_api"> </script>
                          <script type="text/javascript" src="sof.js"> </script>
                      </head>
                      <body>
                          <div id="player"></div>
                      </body>
                  </html>
                  

                  还有 JavaScript (sof.js):

                  And the JavaScript (sof.js):

                  var player;
                  // This function creates an <iframe> (and YouTube player)
                  // after the API code downloads.
                  function onYouTubePlayerAPIReady() {
                      player = new YT.Player('player', {
                          height: '390',
                          width: '640',
                          videoId: 'u1zgFlCw8Aw',
                          events: {
                              'onStateChange': function (event) {
                                  switch (event.data) {
                                      case -1:
                                          console.log ('unstarted');
                                          break;
                                      case 0:
                                          console.log ('ended');
                                          break;
                                      case 1:
                                          console.log ('playing');
                                          break;
                                      case 2:
                                          console.log ('paused');
                                          break;
                                      case 3:
                                          console.log ('buffering');
                                          break;
                                      case 5:
                                          console.log ('video cued');
                                          break;
                                  }
                              }
                          }
                      });
                  }
                  

                  您可以为每种情况设置一个处理程序.

                  For each case you can set an handler.

                  更多信息:

                  1. YT 播放器入门
                  2. YT Javascript API 事件

                  这篇关于Youtube 嵌入式视频开始/停止事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的视频?)
                  Embed YouTube video - Refused to display in a frame because it set #39;X-Frame-Options#39; to #39;SAMEORIGIN#39;(嵌入 YouTube 视频 - 拒绝显示在框架中,因为它将“X-Frame-Options设置为“SAMEORIGIN)
                  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 播放器静音?)
                      <tbody id='OtkM3'></tbody>

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

                    • <legend id='OtkM3'><style id='OtkM3'><dir id='OtkM3'><q id='OtkM3'></q></dir></style></legend>

                        <tfoot id='OtkM3'></tfoot>
                            <bdo id='OtkM3'></bdo><ul id='OtkM3'></ul>

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