We're using the adrianliaw:youtube-iframe-api
package to display youtube iframes in our project.
This was working fine before but we decided to move certain parts of our project into their own packages. After doing that, I can't seem to get the YT
and YTConfig
object imported into our packge.
This is what I have:
package.js
:
Package.onUse(function(api) {
api.versionsFrom('METEOR@0.9.1.1');
// API Use - Both client and server
api.use([
'ecmascript',
'templating',
'fourseven:scss'
], ['client', 'server']);
// API Use - Client only
api.use([
'adrianliaw:youtube-iframe-api'
], ['client']);
});
youtube-display.js
:
import { YT, YTConfig } from 'meteor/adrianliaw:youtube-iframe-api';
/**
* Video display controller
* Assuming youtube-only for now
*/
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player,
videoId,
videoElement,
isPreview = false,
isMuted = false;
onYouTubeIframeAPIReady = function() {
player = new YT.Player(videoElement, {
height: window.innerHeight,
width: window.innerWidth,
videoId: videoId,
playerVars: {
controls: 0,
showinfo: 0,
modestbranding: 1,
iv_load_policy: 3,
rel: 0
},
events: {
onReady: function (event) {
if ( ! isPreview ) {
// Play video when player ready.
event.target.playVideo();
if ( isMuted ) {
event.target.mute();
}
}
}
}
});
}
Template.HBModule_youtube_Display.onCreated(function() {
videoId = Template.instance().data.media.youtubeId;
if ( Template.instance().data.preview ) {
isPreview = true;
}
if ( Template.instance().data.muted ) {
isMuted = true;
}
});
Template.HBModule_youtube_Display.onRendered(function() {
videoElement = Template.instance().$('.module__video')[0];
// Start
YT.load();
});
Template.HBModule_youtube_Display.onDestroyed(function() {
player.destroy()
});
and I'm getting this error:
_adrianliawYoutubeIframeApi.YT.load is not a function
.
and like I said, minus the import at the top of the display file, this all worked perfect before.
Any help would be appreciated. Thanks!