<legend id='KoRNz'><style id='KoRNz'><dir id='KoRNz'><q id='KoRNz'></q></dir></style></legend>

  • <tfoot id='KoRNz'></tfoot>

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

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

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

        YouTube iFrame API .seekTo() 不是方法?

        YouTube iFrame API .seekTo() not a method?(YouTube iFrame API .seekTo() 不是方法?)

          <tbody id='0qQVw'></tbody>
            <tfoot id='0qQVw'></tfoot>

                <bdo id='0qQVw'></bdo><ul id='0qQVw'></ul>

                <small id='0qQVw'></small><noframes id='0qQVw'>

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

                  本文介绍了YouTube iFrame API .seekTo() 不是方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道 .seekTo() 在 Javascript API 中工作,但我无法让它与 iFrame API 一起工作.支持这种方法吗?下面的代码成功嵌入视频并成功 console.log-s 播放器对象.我在控制台中收到错误player.seekTo 不是函数".

                  I know that .seekTo() works in the Javascript API, but I'm not able to get it working with the iFrame API. Is this method supported? The code below successfully embeds the video and successfully console.log-s the player object. I get the error "player.seekTo is not a function" in the console.

                      <script>
                          var tag = document.createElement('script');
                          tag.src = "http://www.youtube.com/player_api";
                          var firstScriptTag = document.getElementsByTagName('script')[0];
                          firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
                          var player;
                          function onYouTubePlayerAPIReady() {
                              player = new YT.Player('player', {
                                  height: '390',
                                  width: '640',
                                  videoId: 'u1zgFlCw8Aw'
                              });
                          }
                          $(window).load(function(){
                              jQuery('#test').click(function(){
                                  //console.log('test');
                                  console.log(player);
                                  player.seekTo(25);
                                  return false;
                              });
                          });
                      </script>
                      <a href="#" id="test">Test</a>
                  

                  有什么想法吗?谢谢!

                  推荐答案

                  这里是更新的 jsfiddle 使用新的 iframe api作品

                  Here's an updated jsfiddle using the new iframe api that works

                  仅供参考:如果您只是使用 iframe 纯 HTML 嵌入,您可以将 ?start=30 作为开始时间

                  FYI: If you're just using an iframe pure HTML embed you can put ?start=30 for the start time

                  <iframe width="640" height="390" 
                          src="//www.youtube.com/embed/p2H5YVfZVFw?start=30" 
                          frameborder="0" allowfullscreen></iframe>
                  

                  对于 API,您可以像这样在特定时间启动视频.使用 start 参数

                  For the API you can start a video at a certain time like this. Use the start parameter

                  function onYouTubePlayerAPIReady() {
                       player = new YT.Player('player', {
                         height: '390',
                         width: '640',
                         videoId: 'p2H5YVfZVFw',
                           playerVars: { 'start': 159, 'autoplay': 1, 'controls': 1 },
                         events: {
                           'onReady': onPlayerReady,
                           'onStateChange': onPlayerStateChange,
                         }
                  
                       });   
                  

                  您只能在播放器开始播放或不执行任何操作后调用 seekTo.检查 playerStateChange 回调:

                  You can only call seekTo after the player has started playing or it doesn't do anything. Check the playerStateChange callback :

                  onStateChange': onPlayerStateChange
                  

                  添加这个回调函数

                  function onPlayerStateChange(evt) 
                  {       
                      if (evt.data==1) 
                      {
                          // this will seek to a certain point when video starts
                          // but you're better off using 'start' parameter
                          // player.seekTo(22);   
                      }
                  }
                  

                  jsFiddle 底部有按钮,用于寻找 30、60、90 秒.它已经在所有与 'rome' 押韵的浏览器上进行了测试.当它打开时,它会为 player.seekTo 函数类型设置一个警告框.如果这显示未定义",则说明有问题.

                  The jsFiddle has buttons at the bottom to seek to 30, 60, 90 seconds. It has been tested with all browsers that rhyme with 'rome'. When it opens it puts up an alert box for the player.seekTo function type. If this shows 'undefined' you have a problem.

                  这篇关于YouTube iFrame API .seekTo() 不是方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                    • <bdo id='URe6V'></bdo><ul id='URe6V'></ul>
                    • <small id='URe6V'></small><noframes id='URe6V'>

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

                            <tbody id='URe6V'></tbody>
                          • <legend id='URe6V'><style id='URe6V'><dir id='URe6V'><q id='URe6V'></q></dir></style></legend>

                          • <tfoot id='URe6V'></tfoot>