【问题标题】:How to use YouTube API with Gulp (minified file doesn't contain YouTube callback methods)如何在 Gulp 中使用 YouTube API(缩小文件不包含 YouTube 回调方法)
【发布时间】:2015-09-20 09:37:18
【问题描述】:
【问题讨论】:
标签:
javascript
gulp
youtube-javascript-api
laravel-elixir
【解决方案1】:
解决此问题的唯一方法是致电onYouTubeIframeAPIReady()。
为此,我添加了一个条件:
function onYouTubeIframeAPIReady(init) {
if (init === "init") {
return;
}
// Init your YouTube Player here, after the condition.
}
// First call here : The minifier notices the method is used, so it won't delete it
onYouTubeIframeAPIReady("init");
// Later, YouTube API will call this method
// (YouTube doesn't pass any parameters, so the player will be initialized in this case)
// YouTube API : onYouTubeIframeAPIReady();