Commit c5437c46 by Daniel Dahan

migrated CameraView into ViewController for example

parent 0d503a05
......@@ -26,19 +26,39 @@ enum CaptureMode {
}
class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDelegate {
private lazy var cameraView: CameraView = CameraView()
lazy var captureView: CaptureView = CaptureView()
lazy var navigationBarView: NavigationBarView = NavigationBarView(frame: CGRectNull)
lazy var closeButton: FlatButton = FlatButton()
lazy var cameraButton: FlatButton = FlatButton()
lazy var videoButton: FlatButton = FlatButton()
lazy var switchCameraButton: FlatButton = FlatButton()
lazy var flashButton: FlatButton = FlatButton()
lazy var captureButton: FabButton = FabButton()
lazy var captureMode: CaptureMode = .Video
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareCameraView()
prepareCaptureButton()
prepareCameraButton()
prepareVideoButton()
prepareCloseButton()
prepareSwitchCameraButton()
prepareFlashButton()
prepareNavigationBarView()
prepareCaptureView()
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
captureButton.frame = CGRectMake((view.bounds.width - 72) / 2, view.bounds.height - 100, 72, 72)
}
private func prepareCameraView() {
view.addSubview(cameraView)
cameraView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: cameraView)
private func prepareCaptureView() {
view.addSubview(captureView)
captureView.translatesAutoresizingMaskIntoConstraints = false
captureView.delegate = self
MaterialLayout.alignToParent(view, child: captureView)
}
/**
......@@ -49,6 +69,13 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
}
/**
:name: captureSessionFailedWithError
*/
func captureSessionFailedWithError(capture: CaptureSession, error: NSError) {
print(error)
}
/**
:name: captureStillImageAsynchronously
*/
func captureStillImageAsynchronously(capture: CaptureSession, image: UIImage) {
......@@ -75,4 +102,283 @@ class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDeleg
func captureDidFinishRecordingToOutputFileAtURL(capture: CaptureSession, captureOutput: AVCaptureFileOutput, outputFileURL: NSURL, fromConnections connections: [AnyObject], error: NSError!) {
print("Capture Stopped Recording \(outputFileURL)")
}
/**
:name: captureViewDidUpdateRecordTimer
*/
func captureViewDidUpdateRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) {
MaterialAnimation.animationDisabled {
self.navigationBarView.titleLabel!.text = String(format: "%02i:%02i:%02i", arguments: [hours, minutes, seconds])
}
}
/**
:name: captureViewDidStopRecordTimer
*/
func captureViewDidStopRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) {
navigationBarView.titleLabel!.hidden = true
navigationBarView.detailLabel!.hidden = true
navigationBarView.detailLabel!.textColor = MaterialColor.white
}
/**
:name: captureSessionWillSwitchCameras
*/
func captureSessionWillSwitchCameras(capture: CaptureSession, position: AVCaptureDevicePosition) {
if .Back == position {
let img: UIImage? = UIImage(named: "ic_flash_off_white")
captureView.captureSession.flashMode = .Off
flashButton.setImage(img, forState: .Normal)
flashButton.setImage(img, forState: .Highlighted)
}
}
/**
:name: captureSessionDidSwitchCamerapublic s
*/
func captureSessionDidSwitchCameras(capture: CaptureSession, position: AVCaptureDevicePosition) {
if .Back == position {
let img: UIImage? = UIImage(named: "ic_flash_auto_white")
captureView.captureSession.flashMode = .Auto
flashButton.setImage(img, forState: .Normal)
flashButton.setImage(img, forState: .Highlighted)
}
}
/**
:name: handleCameraButton
*/
internal func handleCameraButton(button: UIButton) {
captureButton.backgroundColor = MaterialColor.blue.darken1.colorWithAlphaComponent(0.3)
captureMode = .Photo
}
/**
:name: handleVideoButton
*/
internal func handleVideoButton(button: UIButton) {
captureButton.backgroundColor = MaterialColor.red.darken1.colorWithAlphaComponent(0.3)
captureMode = .Video
}
/**
:name: handleCaptureButton
*/
internal func handleCaptureButton(button: UIButton) {
if .Photo == captureMode {
captureView.captureSession.captureStillImage()
} else if .Video == captureMode {
if captureView.captureSession.isRecording {
captureView.captureSession.stopRecording()
captureView.stopTimer()
cameraButton.hidden = false
videoButton.hidden = false
if let v: Array<UIButton> = navigationBarView.leftButtons {
for x in v {
x.hidden = false
}
}
if let v: Array<UIButton> = navigationBarView.rightButtons {
for x in v {
x.hidden = false
}
}
navigationBarView.backgroundColor = MaterialColor.black.colorWithAlphaComponent(0.3)
} else {
captureView.previewView.layer.addAnimation(MaterialAnimation.transition(.Fade), forKey: kCATransition)
captureView.captureSession.startRecording()
captureView.startTimer()
cameraButton.hidden = true
videoButton.hidden = true
if let v: Array<UIButton> = navigationBarView.leftButtons {
for x in v {
x.hidden = true
}
}
if let v: Array<UIButton> = navigationBarView.rightButtons {
for x in v {
x.hidden = true
}
}
navigationBarView.backgroundColor = nil
}
}
}
/**
:name: handleSwitchCameraButton
*/
internal func handleSwitchCameraButton(button: UIButton) {
var img: UIImage?
captureView.previewView.layer.addAnimation(MaterialAnimation.transition(.Fade), forKey: kCATransition)
if .Back == captureView.captureSession.cameraPosition {
img = UIImage(named: "ic_camera_rear_white")
captureView.captureSession.switchCameras()
} else if .Front == captureView.captureSession.cameraPosition {
img = UIImage(named: "ic_camera_front_white")
captureView.captureSession.switchCameras()
}
switchCameraButton.setImage(img, forState: .Normal)
switchCameraButton.setImage(img, forState: .Highlighted)
}
/**
:name: handleFlashButton
*/
internal func handleFlashButton(button: UIButton) {
if .Back == captureView.captureSession.cameraPosition {
var img: UIImage?
switch captureView.captureSession.flashMode {
case .Off:
img = UIImage(named: "ic_flash_on_white")
captureView.captureSession.flashMode = .On
case .On:
img = UIImage(named: "ic_flash_auto_white")
captureView.captureSession.flashMode = .Auto
case .Auto:
img = UIImage(named: "ic_flash_off_white")
captureView.captureSession.flashMode = .Off
}
flashButton.setImage(img, forState: .Normal)
flashButton.setImage(img, forState: .Highlighted)
}
}
/**
:name: prepareNavigationBarView
*/
private func prepareNavigationBarView() {
navigationBarView.backgroundColor = MaterialColor.black.colorWithAlphaComponent(0.3)
navigationBarView.shadowDepth = .None
navigationBarView.statusBarStyle = .LightContent
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.hidden = true
titleLabel.textAlignment = .Center
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20)
navigationBarView.titleLabel = titleLabel
// Detail label
let detailLabel: UILabel = UILabel()
detailLabel.hidden = true
detailLabel.text = "Recording"
detailLabel.textAlignment = .Center
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel
navigationBarView.leftButtons = [closeButton]
navigationBarView.rightButtons = [switchCameraButton, flashButton]
view.addSubview(navigationBarView)
navigationBarView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(view, child: navigationBarView)
MaterialLayout.alignToParentHorizontally(view, child: navigationBarView)
MaterialLayout.height(view, child: navigationBarView, height: 70)
}
/**
:name: prepareCaptureButton
*/
private func prepareCaptureButton() {
captureButton.pulseColor = MaterialColor.white
captureButton.pulseFill = true
captureButton.backgroundColor = MaterialColor.red.darken1.colorWithAlphaComponent(0.3)
captureButton.borderWidth = .Border2
captureButton.borderColor = MaterialColor.white
captureButton.shadowDepth = .None
captureButton.addTarget(self, action: "handleCaptureButton:", forControlEvents: .TouchUpInside)
view.addSubview(captureButton)
}
/**
:name: prepareCameraButton
*/
private func prepareCameraButton() {
let img4: UIImage? = UIImage(named: "ic_photo_camera_white_36pt")
cameraButton.pulseColor = nil
cameraButton.setImage(img4, forState: .Normal)
cameraButton.setImage(img4, forState: .Highlighted)
cameraButton.addTarget(self, action: "handleCameraButton:", forControlEvents: .TouchUpInside)
view.addSubview(cameraButton)
cameraButton.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomLeft(view, child: cameraButton, bottom: 24, left: 24)
captureView.captureButton = cameraButton
}
/**
:name: prepareVideoButton
*/
private func prepareVideoButton() {
let img5: UIImage? = UIImage(named: "ic_videocam_white_36pt")
videoButton.pulseColor = nil
videoButton.setImage(img5, forState: .Normal)
videoButton.setImage(img5, forState: .Highlighted)
videoButton.addTarget(self, action: "handleVideoButton:", forControlEvents: .TouchUpInside)
view.addSubview(videoButton)
videoButton.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomRight(view, child: videoButton, bottom: 24, right: 24)
captureView.videoButton = videoButton
}
/**
:name: prepareCloseButton
*/
private func prepareCloseButton() {
let img: UIImage? = UIImage(named: "ic_close_white")
closeButton.pulseColor = nil
closeButton.setImage(img, forState: .Normal)
closeButton.setImage(img, forState: .Highlighted)
captureView.closeButton = closeButton
}
/**
:name: prepareSwitchCameraButton
*/
private func prepareSwitchCameraButton() {
let img: UIImage? = UIImage(named: "ic_camera_front_white")
switchCameraButton.pulseColor = nil
switchCameraButton.setImage(img, forState: .Normal)
switchCameraButton.setImage(img, forState: .Highlighted)
switchCameraButton.addTarget(self, action: "handleSwitchCameraButton:", forControlEvents: .TouchUpInside)
captureView.switchCameraButton = switchCameraButton
}
/**
:name: prepareFlashButton
*/
private func prepareFlashButton() {
captureView.captureSession.flashMode = .Auto
let img: UIImage? = UIImage(named: "ic_flash_auto_white")
flashButton.pulseColor = nil
flashButton.setImage(img, forState: .Normal)
flashButton.setImage(img, forState: .Highlighted)
flashButton.addTarget(self, action: "handleFlashButton:", forControlEvents: .TouchUpInside)
captureView.flashButton = flashButton
}
}
......@@ -79,7 +79,6 @@
96D88C731C132ACC00B91418 /* MaterialAnimation.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88BFF1C1328D800B91418 /* MaterialAnimation.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C741C132ACC00B91418 /* MaterialBasicAnimation.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C001C1328D800B91418 /* MaterialBasicAnimation.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C751C132AD500B91418 /* NavigationBarView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C151C1328D800B91418 /* NavigationBarView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96F367031C20B87D00DD91F4 /* CameraView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F367021C20B87D00DD91F4 /* CameraView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -137,7 +136,6 @@
96D88C1B1C1328D800B91418 /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; };
96D88C1C1C1328D800B91418 /* RobotoFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RobotoFont.swift; sourceTree = "<group>"; };
96D88C1D1C1328D800B91418 /* SideNavigationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideNavigationViewController.swift; sourceTree = "<group>"; };
96F367021C20B87D00DD91F4 /* CameraView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CameraView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -235,7 +233,6 @@
96D88C491C13292700B91418 /* Capture */ = {
isa = PBXGroup;
children = (
96F367021C20B87D00DD91F4 /* CameraView.swift */,
96D88BF51C1328D800B91418 /* CaptureView.swift */,
96D88BF71C1328D800B91418 /* CapturePreviewView.swift */,
96D88BF81C1328D800B91418 /* CaptureSession.swift */,
......@@ -518,7 +515,6 @@
96D88C3F1C1328D800B91418 /* RaisedButton.swift in Sources */,
96D88C3C1C1328D800B91418 /* MaterialTransitionAnimation.swift in Sources */,
96D88C361C1328D800B91418 /* MaterialPulseView.swift in Sources */,
96F367031C20B87D00DD91F4 /* CameraView.swift in Sources */,
96D88C1E1C1328D800B91418 /* CaptureView.swift in Sources */,
96D88C2D1C1328D800B91418 /* MaterialDepth.swift in Sources */,
96D88C331C1328D800B91418 /* MaterialLabel.swift in Sources */,
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io> and other CosmicMind contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
import AVFoundation
public enum CaptureMode {
case Photo
case Video
}
public class CameraView : CaptureView, CaptureViewDelegate, CaptureSessionDelegate {
/**
:name: navigationBarView
*/
public var navigationBarView: NavigationBarView = NavigationBarView(frame: CGRectNull)
/**
:name: captureMode
*/
public private(set) lazy var captureMode: CaptureMode = .Video
/**
:name: prepareView
*/
public override func prepareView() {
super.prepareView()
prepareCaptureButton()
prepareCameraButton()
prepareVideoButton()
prepareCloseButton()
prepareSwitchCameraButton()
prepareFlashButton()
prepareNavigationBarView()
}
/**
:name: captureViewDidUpdateRecordTimer
*/
public func captureViewDidUpdateRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) {
MaterialAnimation.animationDisabled {
self.navigationBarView.titleLabel!.text = String(format: "%02i:%02i:%02i", arguments: [hours, minutes, seconds])
}
}
/**
:name: captureViewDidStopRecordTimer
*/
public func captureViewDidStopRecordTimer(captureView: CaptureView, duration: CMTime, time: Double, hours: Int, minutes: Int, seconds: Int) {
navigationBarView.titleLabel!.hidden = true
navigationBarView.detailLabel!.hidden = true
navigationBarView.detailLabel!.textColor = MaterialColor.white
}
/**
:name: captureSessionFailedWithError
*/
public func captureSessionFailedWithError(capture: CaptureSession, error: NSError) {
print(error)
}
/**
:name: captureSessionWillSwitchCameras
*/
public func captureSessionWillSwitchCameras(capture: CaptureSession, position: AVCaptureDevicePosition) {
if .Back == position {
let img: UIImage? = UIImage(named: "ic_flash_off_white")
captureSession.flashMode = .Off
flashButton!.setImage(img, forState: .Normal)
flashButton!.setImage(img, forState: .Highlighted)
}
}
/**
:name: captureSessionDidSwitchCamerapublic s
*/
public func captureSessionDidSwitchCameras(capture: CaptureSession, position: AVCaptureDevicePosition) {
if .Back == position {
let img: UIImage? = UIImage(named: "ic_flash_auto_white")
captureSession.flashMode = .Auto
flashButton!.setImage(img, forState: .Normal)
flashButton!.setImage(img, forState: .Highlighted)
}
}
/**
:name: handleCameraButton
*/
internal func handleCameraButton(button: UIButton) {
captureButton!.backgroundColor = MaterialColor.blue.darken1.colorWithAlphaComponent(0.3)
captureMode = .Photo
}
/**
:name: handleVideoButton
*/
internal func handleVideoButton(button: UIButton) {
captureButton!.backgroundColor = MaterialColor.red.darken1.colorWithAlphaComponent(0.3)
captureMode = .Video
}
/**
:name: handleCaptureButton
*/
internal func handleCaptureButton(button: UIButton) {
if .Photo == captureMode {
captureSession.captureStillImage()
} else if .Video == captureMode {
if captureSession.isRecording {
captureSession.stopRecording()
stopTimer()
cameraButton!.hidden = false
videoButton!.hidden = false
if let v: Array<UIButton> = navigationBarView.leftButtons {
for x in v {
x.hidden = false
}
}
if let v: Array<UIButton> = navigationBarView.rightButtons {
for x in v {
x.hidden = false
}
}
navigationBarView.backgroundColor = MaterialColor.black.colorWithAlphaComponent(0.3)
} else {
previewView.layer.addAnimation(MaterialAnimation.transition(.Fade), forKey: kCATransition)
captureSession.startRecording()
startTimer()
cameraButton!.hidden = true
videoButton!.hidden = true
if let v: Array<UIButton> = navigationBarView.leftButtons {
for x in v {
x.hidden = true
}
}
if let v: Array<UIButton> = navigationBarView.rightButtons {
for x in v {
x.hidden = true
}
}
navigationBarView.backgroundColor = nil
}
}
}
/**
:name: handleSwitchCameraButton
*/
internal func handleSwitchCameraButton(button: UIButton) {
var img: UIImage?
previewView.layer.addAnimation(MaterialAnimation.transition(.Fade), forKey: kCATransition)
if .Back == captureSession.cameraPosition {
img = UIImage(named: "ic_camera_rear_white")
captureSession.switchCameras()
} else if .Front == captureSession.cameraPosition {
img = UIImage(named: "ic_camera_front_white")
captureSession.switchCameras()
}
switchCameraButton!.setImage(img, forState: .Normal)
switchCameraButton!.setImage(img, forState: .Highlighted)
}
/**
:name: handleFlashButton
*/
internal func handleFlashButton(button: UIButton) {
if .Back == captureSession.cameraPosition {
var img: UIImage?
switch captureSession.flashMode {
case .Off:
img = UIImage(named: "ic_flash_on_white")
captureSession.flashMode = .On
case .On:
img = UIImage(named: "ic_flash_auto_white")
captureSession.flashMode = .Auto
case .Auto:
img = UIImage(named: "ic_flash_off_white")
captureSession.flashMode = .Off
}
flashButton!.setImage(img, forState: .Normal)
flashButton!.setImage(img, forState: .Highlighted)
}
}
/**
:name: prepareNavigationBarView
*/
private func prepareNavigationBarView() {
navigationBarView.backgroundColor = MaterialColor.black.colorWithAlphaComponent(0.3)
navigationBarView.shadowDepth = .None
navigationBarView.statusBarStyle = .LightContent
// Title label.
let titleLabel: UILabel = UILabel()
titleLabel.hidden = true
titleLabel.textAlignment = .Center
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20)
navigationBarView.titleLabel = titleLabel
// Detail label
let detailLabel: UILabel = UILabel()
detailLabel.hidden = true
detailLabel.text = "Recording"
detailLabel.textAlignment = .Center
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel
navigationBarView.leftButtons = [closeButton!]
navigationBarView.rightButtons = [switchCameraButton!, flashButton!]
addSubview(navigationBarView)
navigationBarView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(self, child: navigationBarView)
MaterialLayout.alignToParentHorizontally(self, child: navigationBarView)
MaterialLayout.height(self, child: navigationBarView, height: 70)
}
/**
:name: prepareCaptureButton
*/
private func prepareCaptureButton() {
captureButton = FlatButton()
captureButton!.pulseColor = MaterialColor.white
captureButton!.pulseFill = true
captureButton!.backgroundColor = MaterialColor.red.darken1.colorWithAlphaComponent(0.3)
captureButton!.borderWidth = .Border2
captureButton!.borderColor = MaterialColor.white
captureButton!.shadowDepth = .None
captureButton!.addTarget(self, action: "handleCaptureButton:", forControlEvents: .TouchUpInside)
addSubview(captureButton!)
captureButton!.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomRight(self, child: captureButton!, bottom: 24, right: (bounds.width - 72) / 2)
MaterialLayout.size(self, child: captureButton!, width: 72, height: 72)
}
/**
:name: prepareCameraButton
*/
private func prepareCameraButton() {
let img4: UIImage? = UIImage(named: "ic_photo_camera_white_36pt")
cameraButton = FlatButton()
cameraButton!.pulseColor = nil
cameraButton!.setImage(img4, forState: .Normal)
cameraButton!.setImage(img4, forState: .Highlighted)
cameraButton!.addTarget(self, action: "handleCameraButton:", forControlEvents: .TouchUpInside)
addSubview(cameraButton!)
cameraButton!.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomLeft(self, child: cameraButton!, bottom: 24, left: 24)
}
/**
:name: prepareVideoButton
*/
private func prepareVideoButton() {
let img5: UIImage? = UIImage(named: "ic_videocam_white_36pt")
videoButton = FlatButton()
videoButton!.pulseColor = nil
videoButton!.setImage(img5, forState: .Normal)
videoButton!.setImage(img5, forState: .Highlighted)
videoButton!.addTarget(self, action: "handleVideoButton:", forControlEvents: .TouchUpInside)
addSubview(videoButton!)
videoButton!.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomRight(self, child: videoButton!, bottom: 24, right: 24)
}
/**
:name: prepareCloseButton
*/
private func prepareCloseButton() {
let img: UIImage? = UIImage(named: "ic_close_white")
closeButton = FlatButton()
closeButton!.pulseColor = nil
closeButton!.setImage(img, forState: .Normal)
closeButton!.setImage(img, forState: .Highlighted)
}
/**
:name: prepareSwitchCameraButton
*/
private func prepareSwitchCameraButton() {
let img: UIImage? = UIImage(named: "ic_camera_front_white")
switchCameraButton = FlatButton()
switchCameraButton!.pulseColor = nil
switchCameraButton!.setImage(img, forState: .Normal)
switchCameraButton!.setImage(img, forState: .Highlighted)
switchCameraButton!.addTarget(self, action: "handleSwitchCameraButton:", forControlEvents: .TouchUpInside)
}
/**
:name: prepareFlashButton
*/
private func prepareFlashButton() {
captureSession.flashMode = .Auto
let img: UIImage? = UIImage(named: "ic_flash_auto_white")
flashButton = FlatButton()
flashButton!.pulseColor = nil
flashButton!.setImage(img, forState: .Normal)
flashButton!.setImage(img, forState: .Highlighted)
flashButton!.addTarget(self, action: "handleFlashButton:", forControlEvents: .TouchUpInside)
}
}
......@@ -179,7 +179,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
/**
:name: startTimer
*/
internal func startTimer() {
public func startTimer() {
timer?.invalidate()
timer = NSTimer(timeInterval: 0.5, target: self, selector: "updateTimer", userInfo: nil, repeats: true)
NSRunLoop.mainRunLoop().addTimer(timer!, forMode: NSRunLoopCommonModes)
......@@ -189,7 +189,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
/**
:name: updateTimer
*/
internal func updateTimer() {
public func updateTimer() {
let duration: CMTime = captureSession.recordedDuration
let time: Double = CMTimeGetSeconds(duration)
let hours: Int = Int(time / 3600)
......@@ -201,7 +201,7 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
/**
:name: stopTimer
*/
internal func stopTimer() {
public func stopTimer() {
let duration: CMTime = captureSession.recordedDuration
let time: Double = CMTimeGetSeconds(duration)
let hours: Int = Int(time / 3600)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment