iMedia framework tutorial

72 views
Skip to first unread message

Tony Xiao

unread,
Jan 1, 2012, 12:36:32 PM1/1/12
to imedi...@googlegroups.com
Hey guys,

I'm new to iMedia framework and I was wondering if anybody here knows of any tutorial / blog posts discussing how to use it in an application. Thanks a lot and great job guys!  

Tony

PS: Happy New Years!

Robin

unread,
Jan 2, 2012, 6:01:01 AM1/2/12
to imedi...@googlegroups.com
Hey Tony

I'm not an iMedia developer but have spent the last couple weeks working on an app that heavily uses the framework. To my knowledge there exists no tutorial or formal documentation, if I remember correctly there are some docu fragments on the old Google groups wiki but I personally didn't find them very helpful when getting started. Below are some pointers that should give you a quick start:

- Obviously get the git repo from github and compile the test app to see the framework in action. Note that the Objective-Flickr framework is a direct dependency and must be included in every application that uses iMedia (even if you're not using the Flickr parts of it). From what I have seen the framework is pretty much built to use the iMedia Test application, eg. you will find methods related to the GUI of the iMedia application in many controllers of the framework. The .framework build also includes the gui (I guess in case people want to use it as a visual selection tool for users to pick media) but its easy to just use the underlying model stuff.
- The overall structure of the framework appears to be like this:
  - Libraries: These are media type specific, take a look at the IMBLibraryController. If you eg. want to read images you instantiate an IMBLibraryController with the media type kIMBMediaTypeImage. Each media type can/should only have one library controller and each library controller can have a delegate, whose protocol is described in IMBLibraryController.h
  - Parsers: For every source type there is a parser, eg. there is an IMBiPhotoParser, an IMBApertureParser etc. All parsers are managed by the IMBParserController (a singleton) which is responsible for loading and managing parsers. It again can have a delegate which allows you to specify the parsers the controller should load and get notified when parser change.
  - Nodes: One of the main objects you will interact with are nodes. They describe any "object" a parser loads, eg. an album in iPhoto, the iPhoto root node, a project in iMovie etc. The corresponding class is IMBNode and provides access to sub nodes (if there are any), as well as various metadata of the album/project/etc. Nodes get created by parsers and the library controller's delegate can be informed every time a new node is created (if you implement the appropriate method). Note that nodes loaded are (most of the time) just stubs with a little meta information but no sub nodes array or objects array (more on that in the next point) loaded, you need to request the loading of these separately by invoking populateNode: on the appropriate library controller and passing the node you want to get populated.
  - Objects: Encapsulated by IMBObject, these are the gold you are here for: An object either represents an image, movie, bookmark, song or whatever else it is your node contains. Note again that upon initial retrieval of objects from an IMBNode they may only be stubs containing very little metadata, if you need the full information you need to populate them as well (different method though than for nodes, can't remember right now but its not too hard to find once you take a look at the IMBObject class)

As you might have guessed I only really dealt with the image part of iMedia yet so above might be a little bit biased towards how iMedia works with images, not entirely sure how it is with other media types (though the classes appear to be the same, hence I guess the workflow is similar). From my experience the framework is pretty solid and very well thought through with a clean and well commented code base (many many thanks for the hard work!) so looking at the source along with above should give you a good head start into developing with it.

Finally, take a look at this gist for a brief stub of how I bootstrap iMedia in my application as an example: https://gist.github.com/be05750b8a596c3609ec

I hope this gets you started and helps others who want to use the framework, in case anybody finds the above to be inaccurate please let me know. Have fun!

Best,
Robin

Ps. Usually this mailing list is very active, I think people are still recovering from new years eve ;)

Tony Xiao

unread,
Jan 3, 2012, 2:38:20 AM1/3/12
to imedi...@googlegroups.com
Hi Robin,

Thank you so much for the helpful introduction and the sample code, it definitely gives me a good idea where to start. I'll dig into iMedia now and report back any findings :)

Cheers,

Tony

Tony Xiao

unread,
Jan 3, 2012, 4:06:12 PM1/3/12
to imedi...@googlegroups.com
Hey Robin,

Does the project you are working with have ARC enabled? I'm having trouble importing the <iMedia/iMedia.h> framework headers without generating compiler warnings. Do you know any workarounds?

Screenshots of compiler warning.

http://bit.ly/wuewH3

Tony

Jeffrey Early

unread,
Jan 3, 2012, 4:12:50 PM1/3/12
to imedi...@googlegroups.com
Tony,

I don't have this right in front of me, but I did work around those same compiler errors with ARC. I was able to comment out the references to the offending headers in the original referencing files as listed in the error---and then everything compiled fine.

Jeffrey

Robin Guldener

unread,
Jan 3, 2012, 4:15:09 PM1/3/12
to imedi...@googlegroups.com
Hey Tony

No I don't use ARC and I think I don't even have garbage collection enabled on that project. I don't think iMedia is ARC compatible yet, just use garbage collection instead, the performance penalty won't be too bad. Otherwise manage your memory yourself, in most cases it's not that hard.

Cheers,
Robin

Jeffrey Early

unread,
Jan 3, 2012, 4:31:25 PM1/3/12
to imedi...@googlegroups.com
I'm not sure Tony's situation, but in my case I am not compiling iMedia with ARC. iMedia is still being compiled with manual referencing counting, but my referencing program, which includes the iMedia headers, *is* being compiled with ARC.

Jeffrey

Tony Xiao

unread,
Jan 3, 2012, 4:37:26 PM1/3/12
to imedi...@googlegroups.com
Yea, that's exactly my situation. The issue is that methods such as `autorelease` are #defined in iMedia headers, which are imported by the referencing projects, which are disallowed by the ARC enabled compiler. iMedia itself is still being compiled in manual reference counting mode, and used as a framework. I'll try to refactor out the violating headers and submit a pull request. 

Tony Xiao

unread,
Jan 6, 2012, 5:07:32 PM1/6/12
to imedi...@googlegroups.com
Hey Jeffrey,

I managed to add iMedia as a sub-project to my main project and I'm able to use Robin's gist to instantiate iMedia classes and build & run from within Xcode. However, when I try to build for Archive (I added iMedia framework to the copy files build phase), I get a ton of compilation errors, even when none of my classes refer to or even import the iMedia classes. Did you encounter this problem when you were building?

Error Screenshot:

Thanks a lot,

Tony

Robin Guldener

unread,
Jan 6, 2012, 5:22:56 PM1/6/12
to imedi...@googlegroups.com
Hey Tony

Taking a quick look at the screenshot it looks like you didn't properly build and add the Objective-Flickr framework. It's probably easiest to build it once for release, then store the built framework as a static asset of your project and just link to it from your main project (you most likely won't need its Debug symbols even when debugging your project). Make sure that it is included in the "Link Binary with Libraries" build phase as well.

Cheers,
Robin
Reply all
Reply to author
Forward
0 new messages