Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在低带宽上使用youtube API有困难_Javascript_Jquery_Youtube Api - Fatal编程技术网

Javascript 在低带宽上使用youtube API有困难

Javascript 在低带宽上使用youtube API有困难,javascript,jquery,youtube-api,Javascript,Jquery,Youtube Api,我有一个YouTube播放器,它位于引导旋转木马的幻灯片中,该幻灯片位于模板中。下面不包括旋转木马的html: <script type="text/html> <div class="video-container" id="introVideoTmpl"> <iframe width="640" height="480" src="//www.youtube.com/embed/Kn-7OlEVdNM?rel=0&enablejsapi=1" id="

我有一个YouTube播放器,它位于引导旋转木马的幻灯片中,该幻灯片位于模板中。下面不包括旋转木马的html:

<script type="text/html> <div class="video-container" id="introVideoTmpl">
 <iframe width="640" height="480" src="//www.youtube.com/embed/Kn-7OlEVdNM?rel=0&enablejsapi=1" id="videoOne" frameborder="0" allowfullscreen></iframe>
</script>
getPlayerOne生成播放器的实例:

function getPlayerOne() {
    playerOne = new YT.Player('videoOne', {});
}
这个playerOne有一个pauseVideo方法,我会在需要时调用它

它在大多数情况下都可以正常工作,但有时,在带宽较低的情况下,API似乎无法正常加载,pauseVideo也无法工作


如何检查API是否正确加载,以便在必要时暂停视频

设法解决这个问题

我认为问题在于youtube api并没有在低带宽上正确加载,所以我们一起避免了它,而是使用了函数callPlayer

function getPlayerOne() {
    playerOne = new YT.Player('videoOne', {});
}