Videoing an app while running.
This video demonstrates how Trackometer for Android works. My friends were asking me how I shot this. Here is the rig:
This video demonstrates how Trackometer for Android works. My friends were asking me how I shot this. Here is the rig:
I’ve been working with the AIR for Android SDK for a bunch of weeks now and Adobe loved my prototype of Trackometer (info on the iphone version) so much they were going to include it in the Day 2 keynote demos at Google IO. I guess Google put serious time constraints on things and the demos did not happen on the main stage. However, Trackometer was demonstrated in the Adobe booth and the AIR team featured it in their blog. Ted Patrick also included it in his demo in the video below (see 2:00). Adobe also used the Trackometer source code with Flash Builder to do a live demonstration of compiling and moving the application to a device.
Work continues on the Trackometer app. It will have more features than the iPhone version currently has.
Adobe’s recognition is a huge thrill for me and a nod to independent developers. My inclusion in the private prerelease group was a direct result of the 360Flex presentation I gave in San Jose this past March. I have to pass on a big THANK YOU to Andrew Westberg for asking me to co-present a topic and to Tom Ortega/John Wilker for accepting our presentation proposal. This proves that sometimes you just need to get away from your computer, get on a plane, and go and talk to people in the industry. Face to face.
Adobe loves choice. They believe you should be able to develop once and deploy across multiple screens. Or devices. RunningMap Trackometer is a real example of this happening. To the right is a swf that is a proof of concept for an app that is being developed to run on Android-powered devices using Adobe’s AIR for Android runtime. To make the point clear, this swf was compiled from the same source (minus some device specific calls) that is used to compile the app that runs on Android mobile phones.
I have developed apps for the iPhone – one of them award nominated. RunningMap Trackometer for the iPhone was accepted for sale October 2009. I think it is a great platform to develop for and has tons of potential. But, learning Objective-c and Cocoa was and is tough for me. It’s pretty foreign and it still sometimes takes a long time to solve simple things. I have no doubt that will get easier over time and I love to learn new things. Once you get into it Objective-c has an oop-elegance about it. The real barrier in my mind to creating apps for the iPhone is the torturous process you need to go through to test, provision and submit your app so that you have maximized your chances at Apple blessing it and allowing it to be sold on the App Store. Anyone who has been there knows what I am talking about so I will stop there.
Trackometer for Android is not so much a port of the iPhone app as it is a port of the RunningMap.com application itself, with far fewer features. I’ve been developing for the Flash platform for 10 years and, unlike when I program in Objective-c, problems are solved very quickly. The workflow is like butter. And this is full blown Flash. While developing using the AIR for Android SDK, I did not need to change my well-honed workflow in any way, shape or form. RobotLegs is there. GTween is there. Flash Builder goodness. The API is only limited by the new paradigm; MOUSE_OVER, for example, is not possible with a touch interface. In fact there are a host of new APIs. Geolocation for example. And Trackometer uses that. Try to take your laptop for a run and see how fun that is.
So far I am amazed by how well AIR for Android performs on my Motorola Droid.
Getting the app on your phone is SO MUCH EASIER than with iPhone apps. No provisioning etc. Android phones could install Trackometer directly from this blog post if I placed the package here. But I can’t be cause a) Trackometer is not finished and b) the AIR for Android runtime is not released yet. I’m not sure when but I hope to know soon. I can’t wait.
An important lesson I learned today: the onRegister() method of a Mediator in the RobotLegs framework get’s fired when it’s view is added to the stage. This means that the event mappings and event listeners that you place in the onRegister() method will get invoked each time and (assuming you are adding and removing the view multiple times) unless you use the onRemove() method to un-map and remove the event listeners, you will most certainly get a memory leak. Good to know!
This is a little inconvenient because I was hoping that I could use the mediator event handlers to update a view while it is not on the display list. As it turns out, the mediator will not respond to event mappings when it’s view is removed from the stage. Also good to know.
Any input on this appreciated!
It was Ted Patrick‘s fault. He dared to come to Edmonton in January and I was so impressed with his presentation at EFUG that I registered for the first 360Flex conference which was being held at EBay HQ in SJ. Never been there before. Didn’t know anyone there. Friend and fellow Edmontonian Grant Skinner was going (and presenting) and that gave me confidence that at least I would know someone there (as it turned out, he was quite busy with the Adobe peeps and I didn’t see him much).
Leading up to the conference the buzz on the 360Flex website was to sign up on Twitter. I signed up under the name of “brando”. Remember, this is February 2007. NO ONE knew what Twitter was. Seemed like a useless service to me but it gave me a bunch of new Flex-knowing friends and maybe it would help me connect with some people when I got there. Through twitter I met PolyGeek and told him I was going to hunt him down and say hi.
On the flight to San Jose I met another Edmontonian who was going to the conference: Victor Rubba. Great guy. Now I have another friend to hang out with at the conference.
The morning of the first day I walked from my hotel to EBay and in the main entrance and I couldn’t believe my eyes. Thousands of miles from home, feeling like I was not in Kansas anymore, a guy was standing there with an Edmonton Oilers jersey on. (turns out he was from Calgary, which is ironic to the extreme). I met Tom and John for the first time and they offered me Chocolate cake that Tom’s wife made (nice!). They asked me what my Twitter sig was. They said in unison “Ah, Brando”. While waiting for the keynote I was chatting with some guy who looked really familiar to me. I asked him where he was from and he said San Diego. I shrugged and walked away. Sorry, Josh Tynjala, I was out of touch.
After the first session I was getting Danny Patterson to sign his book on Design Patterns for me when I looked up and saw two smiling faces in front of me. Zach Graves and Aaron King were developers on the Y! Maps team. Because RunningMap.com makes good use of Yahoo! Maps, I was pretty active in the maps online group. I had told them I was coming to the event. They found me first. Now I knew I had someone to hang with. GREAT GUYS. Aaron even gave me his staff issued Y! backpack (at Max 2008 Allen Rabinovich asked me where I got it because they are exclusive to Y! employees).
The food was amazing considering what I paid for the event ($150). I phoned my wife while sitting on the green grass by the ponds of coy and she was extremely jealous. Back home it was -15C˚ with snow up your waist. While chatting with Grant and some other guys I did a double take. “Phillip Kerman?” His was the first Actionscript book I have ever read. Chris Cantrell. Can’t miss Mike Chambers. Victor introduced me to Peter McKiernan who showed up on day two with the same shirt as me. LOL. I did in fact find Dan “PolyGeek” Florio and introduce myself. I didn’t chat with him long because I had to run and pee. Er. RunPee.com.
The presentations were amazing. Ely Greenfield’s was my favourite. Deepa Subramaniam. Mike Chambers. They were all great. I went to a presentation on ANT and the speaker, Joe Berkovitz, asked the audience if they were not using version control. I raised my hand then looked behind me. I was the only one with my hand up. Heh. Still don’t. Just kidding. Maybe not.
Ok, this post has gone on too long already and I think you got the point. Sign up for 360|Flex, San Jose, you will meet a ton of people and have your head filled up until it explodes. It’s the best Flex conference out there so sign up!
For ActionScript 3 development I have just begun exploring the Open Source Media Framework (OSMF) and the MVC based framework called RobotLegs. What better way than to use them together? The best way to learn this stuff is to dive in and apply it to real solutions. PLEASE leave a comment if I have gone astray.
You can download the source code here (based on OSMF sprint 8 and RobotLegs 1.0.2).
Here is the working proof of concept with video served by Castfire.com:
This is a longer term goal. The video player presented here is only a proof of concept. Video on the web continues to evolve and now seems like a good time to re-factor some key video player projects to bring them up to date and address new requirements.
Strobe Open Source Media Framework is an Adobe initiative to bring some standards to video player development. I have been itching to get my hands dirty with this new framework to decide for myself if it is worth buying into.
Some may think it is inevitable that OMSF will be over-architechted and therefore full of bloat. I can't really answer that yet. But I can say that I REALLY like the convenience methods that come with the MediaPlayer class. This build is 90k which includes RobotLegs ... acceptable.
Sure, you can build a video player that comes in at 15k. However, as soon as you start adding modern day requirements (CDN services, advert engines, analytics, chapters, xml lists etc) things quickly get complicated. The promise of OSMF is that all these things can be integrated into your video using a plug-in architecture which will greatly ease the burden of development.
Every video player I have worked on to date (other than a few Flex experiments) have been made with Flash Professional which means they need to be compiled from the Flash IDE. Using Flash Builder to compile the application de-couples the workflow from the Flash IDE which makes possible all sorts of interesting ideas.
This does not preclude the use of Flash Professional made libraries that can be used for things like the control bar. After all, the Flash IDE is still really good at some things.
I have made probably a dozen or so custom video players to date. When building one from scratch it does not take tong before it gets complicated: video players are the mothers of all things asynchronous. I have my own particular way of using design patterns and structure but have never took the time to think through a solid framework and ultimately my projects get big enough that they no longer feel like they are on solid ground.
Someone else has thought it through and this is where RobotLegs comes in. I have had a pretty good experience with Cairngorm over the last couple years but it requires the Flex framework. Dependency Injection seems to be the hot topic recently and I have read some good things about RobotLegs so I thought I would give it a try. This video tutorial from John Lindquist helped me to put together this first implementation.
The thought here is that there are other views to manage than just the video player and control bar. RobotLegs will help make these views and OSMF plugins manageable and modular.
Here are a few classes to show how video player events flow through RobotLegs to the DetailsView so that bytes loaded and playback time can get updated. Download the source for the full meal deal.
The MediaPlayerViewMediator class captures the events from MediaPlayerView which sets a property in the model.
The model extends the RobotLegs Actor class can use the RobotLegs dispatch() method so that the event can be listened for from anywhere within the RobotLegs ecosystem.
In this experiment, DetailsViewMonitor listens for the events from the model. Since it is injected with the DetailsView instance, it can hit its property setters with new data.
Reading framework documentation makes my eyes bleed. The only way I can really intrinsically understand how they fit into how I build applications is to use them. RobotLegs is a winner. I have not worked with OSMF enough to have an opinion one way or the other ... it has not reached a dot oh release yet.
FITC Edmonton is rolling into town on October 17-18, 2009. If you live anywhere near Edmonton you would be crazy not to attend. The presenter list is stellar: Grant Skinner, Mike Chambers, Erik Natzke, Charles "Chuck" Freeman, Lee Brimelow, Mario Klingermann just to name a few.
Chuck Freeman (Director of Developer Platform at Ribbit) was the lead developer for Maps at Yahoo! back in 2005 and I am hugely in his debt since Runningmap.com uses this API to this day. Mike "Mesh" Chambers. In the Flash world it doesn't get any bigger than that (I am positive that his Halo toon bleeds movieclips when he is shot). I will be seeing if Stacey Mulcahy deserves her self-assigned moniker "bitchwhocodes". Mario and I will discuss the difficulties we suffer in life over having two n's at the end of our last name.
I am a speaker too. Because of that and since you have gotten this far in the post, I can offer you a discount code. Use the code randy20 and you will get 20% off! See you there!!
Converting FlashVars parameters to properties is an example where you are forced to deal with strings and sometimes these values need to be numbers. I have been annoyed with with my own inconsistencies with how I test to see if the FlashVar casts correctly or should be rejected (because it had a character other than a number in the string). I was discovering that some techniques were giving false negatives. So I spent some time of trying to establish a best practice.
I considered these four techniques for casting a string to a Number:
Below is the AS3 code and the trace results which I used to base my conclusions here.
Results:
Using "as Number" to cast a string to a Number looks like bad news to me. All other techniques preformed as expected. Casting a string such as "foo" using "as Number" to cast is to a strongly typed variable results with a false value when isNaN() is applied to it. This is the false negative I mentioned before. Even casting the string "1337" using "as Number" results in the value 0 which not only fails the falsies ternary test but is wrong.
Conclusions
Discussion
Casting is perhaps the wrong term since I am converting a primitive to an object which isn't true polymorphism, but perhaps string is being treated as an object.
I talked to Ryan Frishberg at the recent 360|Flex in Indianapolis about this. Ryan works on the Flex SDK team at Adobe. He said that "new Number('foo')" make use of conversion methods that are not available to the technique "'foo' as Number" which will evaluate to null since this casting is not possible. String can't be a Number. Ok, that is the d'oh moment for me. Should know better.
It's problematic though, because it fails to report a run-time or compile-time error.
Google has posted a proof of concept showing YouTube using HTML 5.
I was able to view this with Safari. You will note that there is no Flash on this page. Apparently the video tag uses system video resources so if you previously installed a h.264 codec, it should just work. The controls are all HTML. Does this mean the end to dominance of Flash delivered video on the web?