YouTube API未捕获的TypeError:player.stopVideo不是函数 [英] Youtube API Uncaught TypeError: player.stopVideo is not a function
问题描述
我不知道为什么这个功能不起作用.
I have no idea why this function does not work.
我现在在我的网站上使用一个非常简单的示例,单击该链接后,该示例基本上会停止播放视频.参见下面的代码:
I am using now a very simple example on my website which basically stops the video once I click on the link. See code below:
<div id="player"></div>
<a href="#" id="pause">Pause</a>
这就是我在页面底部使用的脚本:
And thats the script I am using in the bottom of the page:
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: '315',
width: '560',
videoId: 'bpOR_HuHRNs',
});
document.getElementById('pause').onclick = function() {
player.stopVideo();
};
}
一旦我单击暂停"链接.我收到错误消息:
Once I click on the Pause link. I get the error:
未捕获的TypeError:player.stopVideo不是函数
Uncaught TypeError: player.stopVideo is not a function
我尝试从google docs实施整个代码: https://developers.google.com/youtube/iframe_api_reference#Getting_Started
I have tried to implement the whole code from google docs: https://developers.google.com/youtube/iframe_api_reference#Getting_Started
同样的问题..这是怎么回事?
Same problem..What is wrong here??
推荐答案
好,发现问题了.如果有人遇到相同的错误,请检查您是否正在使用其他脚本,例如我使用reembed.com.网站脚本将YouTube视频制作为自定义播放器.搞砸了整个YouTube的API
Ok, found the problem.. If someone will come across the same error, check if you are using another scripts, like in my case i used reembed.com websites script to make YouTube video as a custom player. That messed up entire YouTube's API
这篇关于YouTube API未捕获的TypeError:player.stopVideo不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!