PlanetKitCameraManager
public class PlanetKitCameraManager : NSObject
extension PlanetKitCameraManager: PlanetKitVideoOutputDelegate
A class that manages the camera device.
-
The shared instance of the PlanetKitCameraManager.
Declaration
Swift
@objc public static let shared: PlanetKitCameraManager
-
The delegate object that will receive camera events.
Declaration
Swift
@objc public weak var delegate: PlanetKitCameraDelegate? { get set }
-
Starts the camera preview.
This method initiates the camera preview by adding the provided delegate to the preview stream. If the camera is not already started, it will start the camera with the default device.
Declaration
Swift
@objc public func startPreview(delegate: PlanetKitVideoOutputDelegate)
Parameters
delegate
An object conforming to
PlanetKitVideoOutputDelegate
that will receive the preview stream. -
Stops the camera preview.
This method removes the given delegate from the preview stream’s receivers. If there are no more receivers left, it stops the camera if it is currently running.
Declaration
Swift
@objc public func stopPreview(delegate: PlanetKitVideoOutputDelegate)
Parameters
delegate
The delegate that should stop receiving the preview stream.
-
Gets or sets the preview modifier.
This property is used to modify the video stream for preview purposes. The delegate conforms to the
PlanetKitVideoModifierDelegate
protocol and provides the necessary methods to apply custom modifications to the video stream.Declaration
Swift
@objc public var previewModifier: PlanetKitVideoModifierDelegate? { get set }
-
Sets a custom camera to the camera manager.
Declaration
Swift
@objc public func setCustomCamera(_ customCamera: PlanetKitCustomCamera)
Parameters
camera
An optional
PlanetKitCameraControllable
object representing the new custom camera to be set. Ifnil
, the current camera will be removed without setting a new one. -
Resets the camera to the default camera.
Declaration
Swift
@objc public func resetToDefaultCamera()
-
Declaration
Swift
public func videoOutput(_ videoBuffer: PlanetKitVideoBuffer)
-
The current video capture device being used by the camera.
Declaration
Swift
@objc public var currentDeviceInfo: PlanetKitVideoCaptureDeviceInfo? { get set }
-
A Boolean value indicating whether the camera is currently started.
Declaration
Swift
@objc public var isStarted: Bool { get }
-
The preset configuration for the camera.
Declaration
Swift
@objc public var preset: PlanetKitCameraPreset? { get }
-
The position of the camera.
Declaration
Swift
@objc public var position: PlanetKitCameraPosition { get }
-
The frame rate of the camera.
Declaration
Swift
@objc public var frameRate: PlanetKitFrameRate? { get }
-
Changes the camera device.
Declaration
Swift
@objc public func change(deviceInfo: PlanetKitVideoCaptureDeviceInfo)
Parameters
device
The new video capture device to use.
-
Switches the position of the camera (front or back) on iOS devices.
-
Adds a receiver to handle camera interruption events.
-
Removes a receiver from handling camera interruption events.
-
Gets or sets the virtual background.
Remark
ThevirtualBackground
property is available on iOS 15.0 and macOS 12.0 or newer versions. SetvirtualBackground
with desiredPlanetKitVirtualBackground
settings to apply a virtual background. SetvirtualBackground
tonil
to remove the virtual background. The default value isnil
. For iOS: Due to the segmentation performance requirements, we recommend using this feature for iPhone 12 or newer models.Declaration
Swift
@available(iOS 15.0, macOS 12.0, *) @objc public var virtualBackground: PlanetKitVirtualBackground? { get set }
-
Returns an array of available video capture devices
Declaration
Swift
@objc public var deviceInfos: [PlanetKitVideoCaptureDeviceInfo] { get }
-
A property that indicates whether the camera is available on the current platform.
Declaration
Swift
@objc public static var isCameraAvailable: Bool { get }
Return Value
true
if the camera is available,false
otherwise.
-
Adds a device change delegate to the camera.
Declaration
Swift
@objc public func addDeviceChangeDelegate(_ delegate: PlanetKitCameraDeviceChangeDelegate)
Parameters
delegate
The delegate to be added.
-
Removes a device change delegate from the camera.
Declaration
Swift
@objc public func removeDeviceChangeDelegate(_ delegate: PlanetKitCameraDeviceChangeDelegate)
Parameters
delegate
The delegate to be removed.