CocoaPods trunk is moving to be read-only. Read more on the blog, there are 12 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Jun 2017 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by Lawrence Tran.
Gif Camera Controller is a camera output that takes successive photos to create GIFs.
Instantiate a GifCameraController and run setupSession() in a do-catch statement. To see the camera’s preview use a GifCameraPreview view. Note that GifCameraPreview is currently not supported in interface builder. You must instantiate in code.
var gifCamera: GifCameraController!
var previewView: GifCameraPreviewView!
self.gifCamera = GifCameraController()
do {
if try self.gifCamera.setupSession() {
self.gifCamera.setPreviewView(self.previewView)
}
} catch let error as NSError {
self.gifCamera = nil
print(error.localizedDescription)
}
Then set the duration and frames per second.
self.gifCamera.maxDuration = 2.0
self.gifCamera.framesPerSecond = 3Begin the capture session and start recording.
self.gifCamera.startSession()
self.gifCaemra.startRecording()When recording finishes, the delegate will output the frames.
var delegate: GifCameraControllerDelegateThe delegate for the camera controller. This must be set.
var maxDuration: DoubleThe maximum duration of the gif. Defaults to 4 seconds.
var framesPerSecond: IntThe capture rate of the camera. Defaults to 18 fps.
var currentDevicePosition: AVCaptureDevicePositionThe current device position. (read-only)
func setupSession() throws -> BoolSetup the camera controller. This must be called before the sessiong begins.
func setPreviewView(view: GifCameraPreviewView)Adds a preview view to the camera controller. You must instantiate GifCameraPreviewView in code.
func startSession()Starts the capture session.
func stopSession()Stops the capture session.
func isRecording() -> BoolReturns if session is recording.
func startRecording()Starts recording.
func pauseRecording() Pauses recording. Does not reset current parameters.
func cancelRecording()Stops recording and resets all variables.
func stopRecording()Ends the recording.
func toggleCamera()Toggles between the front camera and the back. Note GifCameraController defaults to the front camera.
func toggleTorch(forceKill forceKill: Bool) -> BoolToggles the torch and returns if the torch is on. Set forceKill to true to turn off the torch.
func cameraController(cameraController: GifCameraController, didFinishRecordingWithFrames frames: [CGImage], withTotalDuration duration: Double)Returns to the delegate the bitmaps the frames along with the duration of the gif. This is called with stopRecording() or when maxDuration is reached.
func cameraController(cameraController: GifCameraController, didAppendFrameNumber index: Int)Notifies the delegate that a frame was appended.
To run the example project, clone the repo, and run pod install from the Example directory first.
GifCameraController is available through CocoaPods. To install it, simply add the following line to your Podfile:
use_frameworks!
pod "GifCameraController"Lawrence Tran
See the LICENSE file for more info.