menu

SpecFM

A network of designers and developers making the best podcasts, blogs, and resources for designers and developers.

Channels
# All channels
view-forward
# General
view-forward
# Assemble
view-forward
# Design
view-forward
# Design Details
view-forward
# Design Systems
view-forward
# Developer Tea
view-forward
# Does Not Compute
view-forward
# Fragmented
view-forward
# Framework
view-forward
# Immutable
view-forward
# inspect
view-forward
# Jobs
view-forward
# Layout
view-forward
# Music
view-forward
# Orthogonal
view-forward
# Programming
view-forward
# Reactpodcast
view-forward
# Research
view-forward
# Runtime
view-forward
# show-n-tell
view-forward
# Specifics
view-forward
# Swift Unwrapped
view-forward
# Toolsday
view-forward
# Typography
view-forward
Team

#303: Editing Videos in UIKit ๐Ÿ“ผ

March 10, 2017 at 6:07pm

#303: Editing Videos in UIKit ๐Ÿ“ผ

March 10, 2017 at 6:07pm
Today we're continuing our hunt for hidden gems in UIKit with UIVideoEditorController.
It's a cousin to UIImagePickerViewController that exposes <i>just</i> the basic video editing functionality from that class in a standalone, dedicated video editing view controller.
Let's give it a try.
First, we'll need a video file to edit. We'll use this one which is part of a freely available collection.
We'll download the video, rename it to something simple, and drag it into Xcode. We'll check the box next to our app in the dialog that appears, so it gets copied to our app target.
Now, let's write some code.
First, we'll make sure our video can be found:
...and that UIKit knows how to edit it:
Nice. Next, we can create a new video editor view controller and configure a few things on it:
Here we've told it our path, and given it a 10 second max duration. (Pro Tip: Default is 10 minutes, set to 0 for no max).
From here we can simply present it like any other view controller:
Neat!
The best part is all the functionality is self-contained inside the view controller.
The user can scrub through:
<img src="http://media.littlebitesofcocoa.com.s3.amazonaws.com/303-1.png" style="max-width: 640px; border-radius: 4px;" />
Trim the edges:
<img src="http://media.littlebitesofcocoa.com.s3.amazonaws.com/303-2.png" style="max-width: 640px; border-radius: 4px;" />
Then save the video back to the videoPath we set earlier:
<img src="http://media.littlebitesofcocoa.com.s3.amazonaws.com/303-3.png" style="max-width: 640px; border-radius: 4px;" />
Note: The documentation mentions UIVideoEditorController <i>"only supporting Portrait"</i> orientations, but it seems to work fine in all orientations.
Last but not least, we can (optionally) set a delegate on our UIVideoEditorController to get notified when the user saves or cancels (or a save fails):
That's all for today. Know of an interesting UIKit B-side?
<p></p>

March 10, 2017 at 6:07pm
Just testing out what it might be like to public LBOC natively in Spectrum. No promises, just playing around. Very cool to see such great markdown support so early on in Spectrum's life. Cheers all!
  • reply
  • like
*publish
  • reply
  • like
SO GREAT
  • reply
  • like
this exposed so many issues!
  • reply
  • like
thank you Jakey Cakes!
  • reply
  • like
hehe happy to help
  • reply
  • like
you know me, i'm *awesome* at breaking things
  • reply
  • like
:)
  • reply
  • like