Nike+ AS3 Library

Okay so I'm not the most athletic person in the world, but one thing that does get me out of the house is tracking how far I've been running. Watching the km's tick over!


But I'm sick of iTunes and having to log into nike online all the time. So I got bored this weekend and the result is the start of a new little as3 interface using the content from my Nike+ device. Initially this library just processes files that nike+ stores on the device, but would eventually like it to access the online service as well.

The NikePlus class represents the base of the Nike+ interface. With this interface you can load a series of workouts from their xml files and use the data stored therein for other applications.

The workouts are stored as xml files on the devices at a location similar to the below, (you may have to enable filesystem access in itunes to be able to see this):

[DEVICEMOUNTPOINT]/iPod_Control/Device/Trainer/Workouts/Empeds/[NIKEPLUSID]/

Underneath this directory the data is setup as follows:

  • latest/*.xml - A series of xml workout files that haven't been synced
  • synched/*.xml - A series of xml workout files that have been synced
  • lastWorkout.xml - The last xml workout file
  • preferences.xml - Nike+ preferences xml file

You can get the library here:
svn co http://svn.labs.distriqt.com/public/trunk/nikeplus/trunk

Usage of the library is relatively simple at this stage:

  1. var _nikeplus:NikePlus = new NikePlus();
  2. _nikeplus.addEventListener( NikePlus.LOADED, nikeplus_loadedHandler );
  3. _nikeplus.loadWorkout( _workout_xml_location );
  4.  

Then once loaded:

  1. function nikeplus_loadedHandler( _event:Event ):void
  2. {
  3. for each (var _workout:NikeWorkout in _nikeplus.workouts)
  4. {
  5. trace( _workout.summary.calories );
  6. trace( "Data Interval: "+_workout.intervalValue );
  7. for (var i:int = 0; i < _workout.data.length; i++)
  8. {
  9. trace( "Data Point["+i+"] "+_workout.data[i] );
  10. }
  11. }
  12. }
  13.  

Started building a simple little AIR application to eventually replace iTunes and Nike online. I'll post more when I have a working version.

Published by

Michael

http://michaelarchbold.com

Leave a Reply

Your email address will not be published. Required fields are marked *