Created
July 15, 2015 22:55
-
-
Save acj/218d6f8cfb8bd927d213 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BuildTimelapseViewController.swift | |
// | |
// Created by Adam Jensen on 5/9/15. | |
// | |
import JGProgressHUD | |
import JoePro | |
import UIKit | |
class BuildTimelapseViewController: UIViewController { | |
@IBOutlet weak var resolutionSegmentedControl: UISegmentedControl! | |
@IBOutlet weak var speedSlider: UISlider! | |
@IBOutlet weak var removeFisheyeSlider: UISwitch! | |
var album: String? | |
var camera: JoeProCamera? | |
var timeLapseBuilder: TimeLapseBuilder? | |
init(camera: JoeProCamera, album: String) { | |
self.camera = camera | |
self.album = album | |
super.init(nibName: "BuildTimelapseViewController", bundle: nil) | |
} | |
required init(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
@IBAction func buildButtonTapped(sender: AnyObject) { | |
if let camera = camera, | |
let album = album { | |
let progressHUD = JGProgressHUD(style: .Light) | |
progressHUD.textLabel.text = "Building your timelapse..." | |
progressHUD.indicatorView = JGProgressHUDRingIndicatorView(HUDStyle: .Light) | |
progressHUD.setProgress(0, animated: true) | |
progressHUD.showInView(view) | |
camera.listOfVideos(album) { (videos) -> Void in | |
self.timeLapseBuilder = TimeLapseBuilder(photoURLs: videos) | |
self.timeLapseBuilder!.build( | |
{ (progress: NSProgress) in | |
NSLog("Progress: \(progress.completedUnitCount) / \(progress.totalUnitCount)") | |
dispatch_async(dispatch_get_main_queue(), { | |
let progressPercentage = Float(progress.completedUnitCount) / Float(progress.totalUnitCount) | |
progressHUD.setProgress(progressPercentage, animated: true) | |
}) | |
}, | |
success: { url in | |
NSLog("Output written to \(url)") | |
dispatch_async(dispatch_get_main_queue(), { | |
progressHUD.dismiss() | |
}) | |
}, | |
failure: { error in | |
NSLog("failure: \(error)") | |
dispatch_async(dispatch_get_main_queue(), { | |
progressHUD.dismiss() | |
}) | |
} | |
) | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment