Post |
---|
Appcelerator Cloud Push Notification in Android
Push Notification for Android using Appcelerator Cloud Service(ACS) |
Launch third-party apps from Titanium App
Launch iOS Native(Map,Settings,Browser,..etc)/Third-party applications from our Titanium Application |
Appcelerator Cloud Push Notification in iPhone
Push Notification for iOS using Appcelerator Cloud Service(ACS) |
Appcelerator Cloud Service Custom Object and Query
Custom Objects using >Appcelerator Cloud Service and Query(Order by, Greater than, Less Than, Equal) the Objects |
WebView in Appcelerator Titanium
WebView in Appcelerator Titanium with events explanation |
Tuesday, August 14, 2012
Top 5 Visited Posts
Here are the Top 5 visited post on titaniumtutorial.com based on Google Analytics stats.
Wednesday, August 1, 2012
YouTube Playlist in Titanium
In this post I am going to discuss about how to fetch YouTube playlist from a channel using Appcelerator Titanium.
YouTube offer API for category, search term, playlist, favorites, subscriptions... etc. Here you can found list of YouTube API
https://developers.google.com/youtube/getting_started
Below API will retrieve the user's playlists. This request does not require authentication
https://gdata.youtube.com/feeds/api/users/userId/playlists?v=2
The above API response containing a playlists feed in XML format.
The response contains a series of <entry> tags, with each entry describing a playlist.
Each entry contains the playlist's title, description, author and modification date as well as
a <content> tag that specifies the URL for retrieving the list of videos in the playlist
Here I am using Apple's YouTube username to fetch their YouTube playlist
In below code I am going to retrieve all the videos in a particular playlist using playlist id.
http://gdata.youtube.com/feeds/api/playlists/playlist_id?v=2
Here you can download the complete working project from my Github Titanium YouTube Playlist
CodeStrong
YouTube offer API for category, search term, playlist, favorites, subscriptions... etc. Here you can found list of YouTube API
https://developers.google.com/youtube/getting_started
Below API will retrieve the user's playlists. This request does not require authentication
https://gdata.youtube.com/feeds/api/users/userId/playlists?v=2
* Here userId represents YouTube username.
The above API response containing a playlists feed in XML format.
The response contains a series of <entry> tags, with each entry describing a playlist.
Each entry contains the playlist's title, description, author and modification date as well as
a <content> tag that specifies the URL for retrieving the list of videos in the playlist
Here I am using Apple's YouTube username to fetch their YouTube playlist
var channelName = "apple"; var loader = Titanium.Network.createHTTPClient(); loader.open("GET", "http://gdata.youtube.com/feeds/api/users/"+channelName+"/playlists?v=2"); loader.onload = function() { var doc = this.responseXML.documentElement; var items = doc.getElementsByTagName("entry"); for (var i = 0; i < items.length; i++) { var item = items.item(i); var playlist_title = item.getElementsByTagName("title").item(0).text;//playlist title var vid_count = item.getElementsByTagName("yt:countHint").item(0).text; //video count for this playlist var play_list_id = item.getElementsByTagName("yt:playlistId").item(0).text; //play_list_id } }; loader.onerror = function(e) { alert("Error:"+e.error); }; loader.timeout = 10000; loader.send();
In below code I am going to retrieve all the videos in a particular playlist using playlist id.
http://gdata.youtube.com/feeds/api/playlists/playlist_id?v=2
var loader = Titanium.Network.createHTTPClient(); loader.open("GET", "http://gdata.youtube.com/feeds/api/playlists/" + playlist_id + "?v=2"); loader.onload = function() { var doc = this.responseXML.documentElement; var items = doc.getElementsByTagName("entry"); for (var c = 0; c < items.length; c++) { var item = items.item(c); var thumbnails = item.getElementsByTagName("media:thumbnail"); if (thumbnails && thumbnails.length > 0) { var media = thumbnails.item(0).getAttribute("url"); //thumbnail image var title = item.getElementsByTagName("title").item(0).text; //video title var videoId = item.getElementsByTagName("yt:videoid").item(0).text; //video id } } }; loader.onerror = function(e) { alert("Error:" + e.error); }; loader.timeout = 5000; loader.send();
Playlist listing for Apple |
Video List for Particular Playlist |
CodeStrong
Subscribe to:
Posts (Atom)