Tuesday, August 2, 2016

DRAFT | What in hell this demoniac is up to these days

Another update: A basic prototype of the "skimmer" in Chroma, which lets you skim videos frame-by-frame by sliding the row of frame thumbnails left/right to rewind/forward:

Update: code that lets you play *all* your videos on your iPhone, simultaneously:


I hate writing about demons when I'm writing software. So, like most posts for the past six months or so, this is also a draft, which contains some blurbs I intend to wordsmith someday—but have no firm plans to actually do so soon—but with photos and videos of the software I've been writing.

One component of the upcoming Chroma app is the video asset chooser, the prototype for which is shown here. The requirements were to list each video on a user's iPhone, with each video playing simultaneously in a multi-paned window. I went beyond that, having not only achieved flawless playback for all 16 concurrent operations allotted to iPhone 6s Plus, but also by adding a reflection effect under each video window, which simultaneously mirrors the playback of all 16 videos playing in the video window. What's more, is all these things, in addition to smooth scrolling and instantaneous video loading and playback—there's no lag when a user scrolls through the collection, regardless of scrolling speed.

That may sound like a nerd-thing; but, it's really more like a giving-it-your-all-thing. Second-rate software for a problem like the one Chroma intends to help solve is unacceptable, and any developer writing such software should know literally everything about iPhone development and its hardware. That is almost what you would have to know to do what you see in the video (even though it may not look like much to a non-developer.

At the end of this post are specifications for the next version of the asset chooser, which will enable simultaneous playback of all videos in a user collection that will fit on their iPhone display, with smooth scaling (in addition to all the above features, of course). Using the pinch gesture, the user will be able to adjust the number of videos displayed at one time.

A feat of software-engineering prowess: a collection view, listing all videos on an iPhone, by which you select a video (in this case, within the upcoming Chroma app) first by scrolling to it, and then touching it—while each video plays in its preview window in real-time, as does the mirrored reflection below it, and while achieving perfectly smooth scrolling performance and instant playback as each videos slides onto the screen:

A solid understanding of threading (concurrency) and blocks is required to achieve this effect, not to mention an equally solid ability to implement concurrency in an app so as to actually improve performance without adding unnecessary complexity to the app's design. Per Apple, "implementing a correct threading solution [is] extremely difficult, if not impossible to achieve."

No shit. This took me forever, the time taken having postponed the release of Chroma for another month. My programming background was of little avail. iOS programming is not MacOSX programming, the differences greater than just cellphone vs. desktop.

But, the detour was necessary, in that, at the onset of Chroma's development, I lacked the requisite knowledge for deploying an app that would and could perform up to the standards set for it.
Horizontally scrolling collection view, showing a partial listing of all iPhone videos
The video preview cells play their respective videos in real-time, while the reflection simultaneously mirrors playback
By contrast, Apple's Photos app uses static previews (non-moving poster frames) for each video:
The stock Videos folder (Photos App), installed by default on all iPhones

The collection view can play up to 16 videos on-screen, at-a-time
The source code is available via MediaFire.

Specifications for next revision

Here are the specs for the next revision of the asset chooser collection view shown above: