Skip to content

Instantly share code, notes, and snippets.

@mitchellsimoens
Created February 11, 2013 22:26
Show Gist options
  • Save mitchellsimoens/4758205 to your computer and use it in GitHub Desktop.
Save mitchellsimoens/4758205 to your computer and use it in GitHub Desktop.
ST2 Youtube Component
Ext.define('Ux.YouTubePlayer', {
extend : 'Ext.Component',
xtype : 'youtubeplayer',
config : {
url : 'http://www.youtube.com/embed/',
videoId : null
},
getElementConfig : function() {
var tpl = this.callParent();
//The src will come from the updateVideoId method
tpl.children.push({
tag : 'iframe',
reference : 'videoIframe',
//would rather this be in CSS
style : 'width:100%;height:100%;border:0;'
});
return tpl;
},
updateVideoId : function(videoId) {
if (videoId) {
this.videoIframe.set({
src : this.getUrl() + videoId
});
}
}
});
Ext.application({
name : 'Test',
launch : function () {
Ext.Viewport.add({
xtype : 'youtubeplayer',
videoId : 'qsvpvqvApKo'
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment