VKRecorder

public class VKRecorder : NSObject
extension VKRecorder: AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAudioDataOutputSampleBufferDelegate
extension VKRecorder: AVCaptureFileOutputRecordingDelegate
extension VKRecorder: AVCapturePhotoCaptureDelegate
extension VKRecorder: AVCaptureMetadataOutputObjectsDelegate

VKRecorder, Video Capturing

singleton

  • Method for providing a VKRecorder singleton. This isn’t required for use.

    Declaration

    Swift

    public static let shared: VKRecorder

object lifecycle

  • Declaration

    Swift

    public override init()

authorization

  • Checks the current authorization status for the desired media type.

    Declaration

    Swift

    public static func authorizationStatus(forMediaType mediaType: AVMediaType) -> VKRecorderAuthorizationStatus

    Parameters

    mediaType

    Specified media type (i.e. AVMediaTypeVideo, AVMediaTypeAudio, etc.)

    Return Value

    Authorization status for the desired media type.

  • Requests authorization permission.

    Declaration

    Swift

    public static func requestAuthorization(forMediaType mediaType: AVMediaType, completionHandler: ((AVMediaType, VKRecorderAuthorizationStatus) -> Void)? = nil)

    Parameters

    mediaType

    Specified media type (i.e. AVMediaTypeVideo, AVMediaTypeAudio, etc.)

    completionHandler

    A block called with the responding access request result

session start/stop

  • Starts the current recording session.

    Throws

    ‘VKRecorderError.authorization’ when permissions are not authorized, ‘VKRecorderError.started’ when the session has already started.

    Declaration

    Swift

    public func startSession() throws
  • Ends the current recording session.

    Declaration

    Swift

    public func endSession()

preview

  • Freezes the live camera preview layer.

    Declaration

    Swift

    public func freezePreview()
  • Un-freezes the live camera preview layer.

    Declaration

    Swift

    public func unfreezePreview()

capture device switching

mirroring

flash and torch

  • Checks if a flash is available.

    Declaration

    Swift

    public var isFlashAvailable: Bool { get }
  • The flash mode of the device.

    Declaration

    Swift

    public var flashMode: AVCaptureDevice.FlashMode { get set }
  • Checks if a torch is available.

    Declaration

    Swift

    public var isTorchAvailable: Bool { get }
  • Torch mode of the device.

    Declaration

    Swift

    public var torchMode: AVCaptureDevice.TorchMode { get set }

focus, exposure, white balance

  • Checks if focusing at a point of interest is supported.

    Declaration

    Swift

    public var isFocusPointOfInterestSupported: Bool { get }
  • Checks if focus lock is supported.

    Declaration

    Swift

    public var isFocusLockSupported: Bool { get }
  • Checks if focus adjustment is in progress.

    Declaration

    Swift

    public var isAdjustingFocus: Bool { get }
  • The focus mode of the device.

    Declaration

    Swift

    public var focusMode: AVCaptureDevice.FocusMode { get set }
  • The lens position of the device.

    Declaration

    Swift

    public var lensPosition: Float { get set }
  • Focuses, exposures, and adjusts white balanace at the point of interest.

    Declaration

    Swift

    public func focusExposeAndAdjustWhiteBalance(atAdjustedPoint adjustedPoint: CGPoint)

    Parameters

    adjustedPoint

    The point of interest.

  • Changes focus at adjusted point of interest.

    Declaration

    Swift

    public func focusAtAdjustedPointOfInterest(adjustedPoint: CGPoint)

    Parameters

    adjustedPoint

    The point of interest for focus

  • Checks if exposure lock is supported.

    Declaration

    Swift

    public var isExposureLockSupported: Bool { get }
  • Checks if an exposure adjustment is progress.

    Declaration

    Swift

    public var isAdjustingExposure: Bool { get }
  • The exposure mode of the device.

    Declaration

    Swift

    public var exposureMode: AVCaptureDevice.ExposureMode { get set }
  • Changes exposure at adjusted point of interest.

    Declaration

    Swift

    public func exposeAtAdjustedPointOfInterest(adjustedPoint: CGPoint)

    Parameters

    adjustedPoint

    The point of interest for exposure.

  • Adjusts exposure duration to a custom value in seconds. Only available for iOS.

    Declaration

    Swift

    public func expose(withDuration duration: Double, durationPower: Double = 5, minDurationRangeLimit: Double = (1.0 / 1000.0))

    Parameters

    duration

    The exposure duration in seconds.

    durationPower

    Larger power values will increase the sensitivity at shorter durations.

    minDurationRangeLimit

    Minimum limitation for duration.

  • Adjusts exposure to a specific custom ISO value. Only available on iOS.

    Declaration

    Swift

    public func expose(withISO iso: Float)

    Parameters

    iso

    The exposure ISO value.

  • Adjusts exposure to the specified target bias. Only available on iOS.

    Declaration

    Swift

    public func expose(withTargetBias targetBias: Float)

    Parameters

    targetBias

    The exposure target bias.

  • Checks if white balance lock is supported.

    Declaration

    Swift

    public var isWhiteBalanceLockSupported: Bool { get }
  • Checks if an white balance adjustment is progress.

    Declaration

    Swift

    public var isAdjustingWhiteBalance: Bool { get }
  • The white balance mode of the device.

    Declaration

    Swift

    public var whiteBalanceMode: AVCaptureDevice.WhiteBalanceMode { get set }
  • Declaration

    Swift

    public var whiteBalanceTemperature: Float { get set }
  • Declaration

    Swift

    public var whiteBalanceTint: Float { get set }
  • Adjusts white balance gains to custom values.

    Declaration

    Swift

    public func adjustWhiteBalanceGains(_ whiteBalanceGains: AVCaptureDevice.WhiteBalanceGains)

    Parameters

    whiteBalanceGains

    Gains values for adjustment.

frame rate support

  • Changes the current device frame rate.

    Declaration

    Swift

    public var frameRate: CMTimeScale { get set }
  • Changes the current device frame rate within the desired dimensions. Only available on iOS.

    Declaration

    Swift

    public func updateDeviceFormat(withFrameRate frameRate: CMTimeScale, dimensions: CMVideoDimensions)

    Parameters

    frameRate

    Desired frame rate.

    dimensions

    Desired video dimensions.

video capture

  • Checks if video capture is supported by the hardware.

    Declaration

    Swift

    public var isVideoCaptureSupported: Bool { get }
  • Checks if video capture is available, based on available storage and supported hardware functionality.

    Declaration

    Swift

    public var canCaptureVideo: Bool { get }
  • Updates video capture zoom factor.

    Declaration

    Swift

    public var videoZoomFactor: Float { get set }
  • Triggers a photo capture from the last video frame.

    Declaration

    Swift

    public func capturePhotoFromVideo()
  • Enables delegate callbacks for rendering into a custom context. videoDelegate, func vkRecorder(_ vkRecorder: VKRecorder, renderToCustomContextWithImageBuffer imageBuffer: CVPixelBuffer, onQueue queue: DispatchQueue)

    Declaration

    Swift

    public var isVideoCustomContextRenderingEnabled: Bool { get set }
  • Settings this property passes a modified buffer into the session for writing. The property is only observed when ‘isVideoCustomContextRenderingEnabled’ is enabled. Setting it to nil avoids modification for a frame.

    Declaration

    Swift

    public var videoCustomContextImageBuffer: CVPixelBuffer? { get set }
  • Initiates video recording, managed as a clip within the ‘VKRecorderSession’

    Declaration

    Swift

    public func record()
  • Pauses video recording, preparing ‘VKRecorder’ to start a new clip with ‘record()’ with completion handler.

    Declaration

    Swift

    public func pause(withCompletionHandler completionHandler: (() -> Void)? = nil)

    Parameters

    completionHandler

    Completion handler for when pause completes

  • Stops recording session. This forces the current clip to end as opposed to pause(), which only ends the current clip in recordMultipleClips mode

    Declaration

    Swift

    public func stop(withCompletionHandler completionHandler: (() -> Void)? = nil)

photo capture

  • Checks if a photo capture operation can be performed, based on available storage space and supported hardware functionality.

    Declaration

    Swift

    public var canCapturePhoto: Bool { get }
  • Triggers a photo capture.

    Declaration

    Swift

    public func capturePhoto()

AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAudioDataOutputSampleBufferDelegate

  • Declaration

    Swift

    public func captureOutput(_ captureOutput: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)

AVCaptureFileOutputDelegate

AVCapturePhotoCaptureDelegate

ARSession

AVCaptureMetadataOutputObjectsDelegate

  • Declaration

    Swift

    public func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection)

NSNotifications