Ads

Thursday, August 29, 2013

RatingBar Module - Android

RatingBar is an extension that shows a rating in stars. The user can touch/drag to set the rating when using RatingBar.

This module converts native Android RatingBar widget to Titanium component.

Features:
  • Touch/Drag Rating
    User can touch/drag to set the rating when using RatingBar.
  • Number of stars
    User can customize no of stars (or rating items) in RatingBar using using setStars method.
  • stepSize
    User can sets the step size (granularity) of this RatingBar
  • setIsIndicator
    User can sets whether this rating bar is an indicator (and non-changeable by the user).
Using Custom Resources:
If you want to use custom resource in your App you can override default resource. For that you have to place your custom resource inside app_root/platform/android/res or app_root/modules/android/titutorial.ratingbar/0.1/platform/android/res in the same name.

For example, if you want to override star_on image you have to override your custom image with the same name star_on.png

Usage:
var win = Ti.UI.createWindow({
 backgroundColor:'#fff',
 layout : 'vertical'
});

var ratingbar = require('titutorial.ratingbar');

var setRatingButton = Ti.UI.createButton({
 title : 'Set rating 6',
 height : '40dp',
 width : Ti.UI.SIZE,
 top : '30dp'
});
win.add(setRatingButton);

/*
 * Dynamic rating bar
 */
var ratingBar1 = ratingbar.createRatingBar({
 top : '30dp',
 left:15,
 rating : 2,
 stars : 6,
 stepSize : 1.5,
 isIndicator : false
});
win.add(ratingBar1);

var ratingValue = Ti.UI.createLabel({
 text : 'Rating Value : '+ratingBar1.getRating(),
 color : '#000',
 font : {fontSize:'20dp'},
 height : Ti.UI.SIZE,
 width : Ti.UI.SIZE,
 top : '30dp',
 textAlign : 'center'
});
win.add(ratingValue);

ratingBar1.addEventListener('change', function(e) {
 ratingValue.text = "Rating Value : "+e.rating.toString();
});

/*
 * Static rating bar
 */
var ratingBar2 = ratingbar.createRatingBar({
 top : '30dp',
 left:15,
 rating : 3,
 stars : 5,
 stepSize : 1,
 isIndicator : true
});
win.add(ratingBar2);

setRatingButton.addEventListener('click', function() {
 ratingBar1.setRating(6.0);
});

win.open(); 

Download:
Module: https://marketplace.appcelerator.com/apps/6371?1827333944
Source Code: https://github.com/railskarthi/ratingbar

Screenshot:
Titanium RatingBar Module
 

Wednesday, August 7, 2013

Android YouTube Player

Android module that plays videos from YouTube.

This module create an Android activity that allows developers to play videos that are hosted on YouTube. This module is based on Android YouTube player library.

The original code was created by KeyesLabs (www.keyeslabs.com) as part of the Screebl project. The developers wanted the ability to play YouTube-hosted help videos, and wanted those videos to be able to play on any device, even those that didn't have the stock YouTube player app.

Android YouTube Player
NOTE: If module unable to get the RTSP url from YouTube server, then video cannot be played.

Features:
  • Higher Bandwidth Video
    This module plays higher bandwidth video from YouTube server as new Activity.
  • Auto Play
    Without user interaction, video will will play automatically in landscape mode once it is loaded from YouTube server.
  • Video Player Controls
    YouTube video player comes with default controls like play, pause, SeekForward, SeekBackward.
  • Play by Video Id and Playlist Id
    playVideo method takes video id as input parameter and plays video automatcally.
    playPlayListVideo
    method takes playlist id as input parameter then it will play the latest video added to a YouTube playlist.
Usage:
var win = Ti.UI.createWindow({
 backgroundColor : "#fff",
 layout : "vertical"
});

var youtubePlayer = require('titutorial.youtubeplayer');
Ti.API.info("module is => " + youtubePlayer);

/*
 * Play video by videoId
 */
var playVideo = Ti.UI.createButton({
 title : 'Play video',
 height : '40dp',
 width : Ti.UI.SIZE,
 top : '100dp'
});
win.add(playVideo);

playVideo.addEventListener('click', function() {
 youtubePlayer.playVideo("FjMs_imWkFM");
});

/*
 * Play video by playListId
 */
var playPlayListVideo = Ti.UI.createButton({
 title : 'Play playlist video',
 height : '40dp',
 width : Ti.UI.SIZE,
 top : '100dp'
});

playPlayListVideo.addEventListener('click', function() {
 youtubePlayer.playPlayListVideo("PLB03EA9545DD188C3");
});

win.add(playPlayListVideo);

win.open();
Download:
Module: https://marketplace.appcelerator.com/apps/6223?942520925
Source code: https://github.com/railskarthi/YoutubePlayer-Android

Screenshot:
Android YouTube Player
Android YouTube Player