Replicating Beme's Proximity-Record in Swift

Replicating Beme's Proximity-Record in Swift

If you haven't seen Beme yet, you've probably been living under a rock. It's Casey Neistat's new video creation application that uses doesn't show you what you're recording.

I've loved the concept from day one. You cover the proximity sensor on the iPhone and it'll start recording 4 seconds of video and then auto-upload it to their servers.

I wondered how difficult it would be to replicate it and it turns out is actually pretty simple. Essentially it comes down to these steps:

  1. Enable the device's proximity sensor in your app
  2. Create an observer for the proximity sensor state
  3. Use AVFoundation to record video when the sensor is covered up
  4. Do something with the video once it's been recorded utilising AVCaptureFileOutputRecordingDelegate

Making it

I've managed to crudely replicate it in an hour (I say crudely because it has zero error handling and won't ask for permissions before you record. It works though). Here's what it looks like (the screen goes off during record):

SRProximityRecord

If you want to give it a try, I've uploaded the project to GitHub. You'll need the latest Xcode beta to try it though because Swift 2.0.

View Project on Github

These are the two files that do the business:

Come Say Hello! Drop me an email, follow me on Twitter, or check out Cocoon (you totally should, we're doing some cool stuff over there).

About Stephen Radford

Software Engineer. I take a few photos when I'm not stuck behind a keyboard too.

Leicester, UK http://stephenradford.co.uk

Comments