我,当我试图运行下面的HTML代码歌厅错误Uncaught ReferenceError: Twitch is not defined
:加载抽搐播放器失败,抽搐没有定义
<div class="custom-box well" id="templateHolder">
<script src="https://player.twitch.tv/js/embed/v1.js"></script>
<div id="testDivId"></div>
<script type="text/javascript">
var options = {width:600,height:400,channel:"cookingForNoobs"};
var player = new Twitch.Player("testDivId", options);
player.setVolume(0.5);
</script>
</div>
当我的jsfiddle它的工作原理,并没有抱怨没有发现运行Twitch
。不过,作为我的页面的一部分,它的确如此。该页面正确加载,除了这个div。也使用<iframe src="http://player.twitch.tv/?channel=cookingfornoobs&muted=true" width="100%" height="800px"></iframe>
将工作。我不确定是否有阻止加载Twitch播放器的呼叫。
有什么我可以检查,以确保其被正确处理?
作为一个说明,它发生在Chrome和Firefox中,我可以在sources选项卡下看到player.twitch.tv js/embed v1.js文件。
https://www.giantbomb.com/forums/bug-reporting-33/chrome-41-0 -2272-76-not-loading-embeded-twitch-pla-1767513/ –
我检查过,不幸的是它不是铬问题,而且我没有遇到网络错误只有Twitch未定义的错误。我还看到了sources标签中的twitch v1.js。 – Niru
@Niru。当解释新的Twitch.Player时,您的库可能仍在加载。尝试使用document.addEventListener(“DOMContentLoaded”或window.onload。 – karthick