// I just Test it in iOS But i think it also work fine in android :)
// The Best part is in this example is http://translate.google.com/translate_tts?tl=en&q= . Google provide us this link to easily convert any text in to speech .
index.xml
<Alloy>
<Window class="container">
<Label id="label" onClick="doClick">Sound Play with the use of google translater Click Here.</Label>
</Window>
</Alloy>
index.tss
".container": {
backgroundColor:"white"
},
"Label": {
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#000"
}
index.js
function doClick(e) {
var name = 'Appcelerator is Very Good Platform'; // You can write any thing here :)
var googleUrl = 'http://translate.google.com/translate_tts?tl=en&q=' + name;
var xhr = Titanium.Network.createHTTPClient();
xhr.open("GET", googleUrl);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onerror = function(e) {
alert('On Error');
}
xhr.onload = function() {
var player = Ti.Media.createSound({
url : googleUrl
});
player.play();
}
}
$.index.open();
Screen Shot : )
No comments:
Post a Comment