Last active
December 15, 2015 04:19
-
-
Save jbuda/5201116 to your computer and use it in GitHub Desktop.
YouTube API Controller Sencha touch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define 'youtube.controller.Videos' | |
extend:'Ext.app.Controller' | |
requires:[ | |
'Ext.data.proxy.JsonP' | |
] | |
config: | |
refs: | |
videosList:'videoslist' | |
control: | |
videosList: | |
initialize:'onVideosListInitialize' | |
onVideosListInitialize:(target,event,options)-> | |
this.getVideosList().setMasked({ | |
xtype:'loadmask' | |
message:'Loading...' | |
}) | |
Ext.data.JsonP.request({ | |
scope:this | |
url:"http://gdata.youtube.com/feeds/api/users/barclaysfootballtv/uploads/" | |
params: | |
'v':2 | |
'alt':'json' | |
success:(result,request)-> | |
entries = result.feed.entry; | |
c = Ext.ModelManager.getModel("youtube.model.Video"); | |
for entry in entries | |
u = Ext.create(c,{ | |
title:entry.title.$t | |
thumbnail:entry.media$group.media$thumbnail[0].url | |
href:entry.link[0].href | |
}) | |
Ext.getStore("Videos").add(u) | |
this.getVideosList().setMasked(false) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment