Tuesday, 2 August 2011

iOS development and PhoneGap

I have spent some time recently working on iOS projects, mainly revolving around displaying web content and doing some fancy stuff with HTML5 such as drawing and annotating on a video. I faced several problems, partly from trying to develop an app using HTML & Javascript and also from the limitations of iOS.

HTML5 ...a work in progress
Now take the HTML5 video element for example. Now I don't want to enter the already heated debate around video formats, I want to talk about the underlying video element. Firstly you would think it would be easy to detect if a video is playing though an attribute such as VideoElement.isPlaying however you would be mistaken, instead you have to:

Check if the Video has loaded
Check if the Video isn't paused
Check if the Video  isn't buffering
Check if the Video hasn't ended
Check if there hasn't been an error

Easy I know... and then there are subtitles, or lack of them, their support is rather hit an miss. I tried to use SAMI subtitles (although I know this is an obscure format, this is what I had to work with) regrettably the video element doesn't support them so I had to develop a way of rendering them myself. That didn't sound so bad to begin with, SAMI is just sugar coated XML, which the XmlDOM parser won't correctly load, horray!

In the end I had to create my own SAMI parser and use transparent DIVs infront of the video element to render the correct subtitles during the videos on time change event. All in a days work!

To make things easier I have started to use PhoneGap, which includes a growing API accessible via Javascript and best of all, allows the programmer to write plugin modules in Objective-C which can communicate with the DOM. This is where I really started noticing the iOS Objective-C libraries are no where near as mature as .Net, I even began to miss importing System.

No comments: