Titanium is fairly new on the scene. It’s an open source platform for building desktop applications using Javascript, CSS and HTML. It’s very similar to Adobe’s AIR. Like AIR, it uses Webkit for the rendering, which makes things like rounded corners very easy. I’m a big AIR fanboy, but i wanted to give this a go. I downloaded the SDK and started messing around by editing the demo file they provide. I stripped out appcelerator, preferring to use pure jQuery instead. On the HTML/Javascript side of things, everything worked perfectly. But some gaps started to appear when I tried using some of their API functions.
I tried making a basic mp3 player. To do this i made a new project. I then stripped out all of the ‘garbage’ out of the auto generated files. This involved deleting the appcelerator include scripts, cleaning the stylesheets out of things i didn’t need, setting the app to use system chrome and deleteing most of the code out of the index.html file.
app create:project . player titanium
I added my own buttons into the index.html file.
<input type="submit" value="Play" id="play" /><br /> <input type="submit" value="Pause" id="pause" /> <br /> <input type="submit" value="Resume" id="resume" /><br /> <input type="submit" value="Select File" id="open" /><br /> <input type="submit" value="Stop" id="stop"><br /><br /> <input type="submit" value="+" id="increasevolume" /> <input type="submit" value="-" id="decreasevolume" />
And made a custom.js script to put my javascript code into. I also put a sound file, ff.mp3, into the package/public/audio/ directory.
$(document).ready(function(){ var s = ti.Media.createSound("app://audio/ff.mp3"); $("#pause").click(function(){ s.pause(); }); $("#play").click(function(){ s.play(); }); $("#resume").click(function(){ s.resume(); }); $("#stop").click(function(){ s.stop(); }); });
This worked pretty well. When i pushed play the music would start, it would also pause and resume fine. If you kept hitting the play button, it would play more and more instances of the same song, it sounded pretty cool after awhile. It’s an obvious design flaw though and could easily be cured by adding
$(this).hide(); when the play button is clicked.
I then tried working with the volume controls, this is where i encountered some problems. (I did the equivilant code for increasing).
$("#decreasevolume").click(function(){ volume = s.getVolume(); decreasedvolume = volume - 1; s.setVolume(decreasedvolume); });
I found I could get the volume fine (alerting it during testing) but whenever i tried to set it, the music stopped playing. Whats more I could resume it or start it again. I’m not sure whether this is a problem in this very early release, or simply due to my bad coding (and the lack of documentation describing how to do these things properly). Another strange problem I had was during the compiling of the program. It would always compile to be adleast 19mb. I thought this was very strange, so i did a bit more testing. I added some large files in there, but the file size would always be 19mb + Other files I had added.
I think Titanium has alot of potential. I’m not too worried about these bugs as it is a preview release. I’m definately keeping an eye on this and will blog about it more in the future
If your interested in Titanium, watch the screencasts.
Follow me on Twitter
Subscribe to my StumbleUpon
Subscribe to the RSS Feed
Great writeup … Sorry for some of the problems you’re having — we’re still trying to finalize some of the API and work out bugs and differences in the platform. We wanted to get the release out early so we could get feedback on the APIs and work with the community to help define and prioritize what everyone wants. Your feedback is very very welcome.
On the file size, in PR1, we include all the 3rd party dependencies like Webkit. In PR2, we’ll be introducing the ability to create separate application archives from the runtime.
Thanks so much for your interest! Let us know how we can improve - we’re listening and working hard to make titanium the best product around.
Jeff
Thanks Jeff, I’m definately looking foward to further documentation and future releases. Expect more posts (and apps) from me in the future.
Hi, my name is Trevor and I am with Appcelerator. I saw that you wrote an article on your experiences with Titanium. This is very helpful in the fact that it helps to get Appcelerator’s name out. As a thank you, we here at Appcelerator would like to send you an Appcelerator t-shirt and a wrist band. It would be great if you could send me your address and we ill makes sure to send you the apparel. Thank you again.
Trevor and the Appcelerator team.