NextLevel

public class NextLevel: NSObject

⬆️ NextLevel, Rad Media Capture in Swift (http://nextlevel.engineering)

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

    Declaration

    Swift

    public static let shared = NextLevel()
  • Undocumented

    Declaration

    Swift

    public class NextLevel: NSObject
  • Checks the current authorization status for the desired media type.

    Parameter

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

    Returns

    Authorization status for the desired media type.

    Declaration

    Swift

    public func authorizationStatus(forMediaType mediaType: AVMediaType) -> NextLevelAuthorizationStatus
  • Requests authorization permission.

    Parameter

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

    Declaration

    Swift

    public func requestAuthorization(forMediaType mediaType: AVMediaType)
  • Starts the current recording session.

    Throws

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

    Declaration

    Swift

    public func start() throws
  • Stops the current recording session.

    Declaration

    Swift

    public func stop()
  • Freezes the live camera preview layer.

    Declaration

    Swift

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

    Declaration

    Swift

    public func unfreezePreview()
  • Checks if a flash is available.

    Declaration

    Swift

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

    Declaration

    Swift

    public var flashMode: NextLevelFlashMode
  • Checks if a torch is available.

    Declaration

    Swift

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

    Declaration

    Swift

    public var torchMode: NextLevelTorchMode
  • Checks if focusing at a point of interest is supported.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public var focusMode: NextLevelFocusMode
  • Focuses, exposures, and adjusts white balanace at the point of interest.

    Parameter

    Parameter adjustedPoint: The point of interest.

    Declaration

    Swift

    public func focusExposeAndAdjustWhiteBalance(atAdjustedPoint adjustedPoint: CGPoint)
  • Changes focus at adjusted point of interest.

    Parameter

    Parameter adjustedPoint: The point of interest for focus

    Declaration

    Swift

    public func focusAtAdjustedPointOfInterest(adjustedPoint: CGPoint)
  • Checks if exposure lock is supported.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public var exposureMode: NextLevelExposureMode
  • Changes exposure at adjusted point of interest.

    Parameter

    Parameter adjustedPoint: The point of interest for exposure.

    Declaration

    Swift

    public func exposeAtAdjustedPointOfInterest(adjustedPoint: CGPoint)
  • Calculates focal length and principle point camera intrinsic parameters for OpenCV. (see Hartley’s Mutiple View Geometry, Chapter 6)

  • Parameters:

    • focalLengthX: focal length along the x-axis
    • focalLengthY: focal length along the y-axis
    • principlePointX: principle point x-coordinate
    • principlePointY: principle point y-coordinate
  • Returns

    true when the focal length and principle point parameters are successfully calculated.

    Declaration

    Swift

    public func focalLengthAndPrinciplePoint(focalLengthX: inout Float, focalLengthY: inout Float, principlePointX: inout Float, principlePointY: inout Float) -> Bool
  • Changes the current capture device’s mirroring mode.

    Declaration

    Swift

    public var mirroringMode: NextLevelMirroringMode
  • Changes the current device frame rate.

    Declaration

    Swift

    public var frameRate: CMTimeScale
  • Changes the current device frame rate within the desired dimensions.

    • Parameters:
      • frameRate: Desired frame rate.
      • dimensions: Desired video dimensions.

    Declaration

    Swift

    public func updateDeviceFormat(withFrameRate frameRate: CMTimeScale, dimensions: CMVideoDimensions)
  • Checks if video capture is supported by the hardware.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    public var videoZoomFactor: Float
  • 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 nextLevel(_ nextLevel: NextLevel, renderToCustomContextWithImageBuffer imageBuffer: CVPixelBuffer, onQueue queue: DispatchQueue)

    Declaration

    Swift

    public var isVideoCustomContextRenderingEnabled: Bool
  • 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?
  • Initiates video recording, managed as a clip within the ‘NextLevelSession’

    Declaration

    Swift

    public func record()
  • Pauses video recording, preparing ‘NextLevel’ to start a new clip with ‘record()’

    Declaration

    Swift

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

    Parameter

    Parameter completionHandler: Completion handler for when pause completes

    Declaration

    Swift

    public func pause(withCompletionHandler completionHandler: (() -> Void)?)
  • Checks if a photo capture operation can be performed, based on available storage space and supported hardware functionality.

    Declaration

    Swift

    public var canCapturePhoto: Bool
  • Triggers a photo capture.

    Declaration

    Swift

    public func capturePhoto()