PlanetKitAudioManager

public class PlanetKitAudioManager : NSObject

A class that manages audio processing.

  • Indicates whether the VoiceProcessingIO is enabled.

    Setting this property to true enables the VPIO feature, while setting it to false disables it. The default value is true for iOS and false for macOS.

    Remark

    This property is reflected identically to PlanetKitAudio.shared.vpioEnabled.

    Declaration

    Swift

    @objc
    public var vpioEnabled: Bool { get set }
  • spk

    The speaker instance that controls the audio playback.

    Declaration

    Swift

    @objc
    public var spk: PlanetKitAudioSpkControllable? { get set }
  • mic

    The microphone instance that controls the audio capture.

    Declaration

    Swift

    @objc
    public var mic: PlanetKitAudioMicControllable? { get set }
  • A Boolean value indicating whether the microphone is enabled or disabled.

    Declaration

    Swift

    @objc
    public var micEnabled: Bool { get set }
  • A Boolean value indicating whether the speaker is enabled or disabled.

    Declaration

    Swift

    @objc
    public var spkEnabled: Bool { get set }

Instance Management

  • Queries whether the audio device instance is opened.

    Declaration

    Swift

    @objc
    public var isOpened: Bool { get }
  • Queries whether the audio device instance is started.

    Declaration

    Swift

    @objc
    public var isStarted: Bool { get }
  • Creates an audio processing unit instance and configures AVAudioSession.

    iOS Only

    If you have configured PlanetKitAudio.shared.openSettings, the configuration of AVAudioSession will be changed to the configuration of PlanetKitAudio.shared.openSettings.

    Declaration

    Swift

    @objc
    public func open()
  • Starts audio processing.

    iOS Only

    It will call AVAudioSession.sharedInstance().setActive(true) internally.

    Declaration

    Swift

    @objc
    public func start()
  • Stops audio processing.

    Declaration

    Swift

    @objc
    public func stop()
  • Releases the audio processing unit instance and resets AVAudioSession.

    iOS Only

    If you have configured PlanetKitAudio.shared.closeSettings, the configuration of AVAudioSession will be changed to the configuration of PlanetKitAudio.shared.closeSettings.

    Declaration

    Swift

    @objc
    public func close()
  • Sets the audio route to its default value.

    Declaration

    Swift

    @objc
    public func setDefaultAudioRoute(_ hasVideo: Bool)
  • Attempts to change the audio route to the speaker temporarily. You can check whether the state has been changed internally with a periodic query on isSpeakerOut for value changes.

    Remark

    If the current audio route changed by connecting with a Bluetooth audio device, it will be reset by the system. See more details on QA1754. You can also change the audio route using AVRoutePickerView.
  • Sets the category and options for the audio session.

  • Indicates whether the speakerphone is enabled.

  • Sets the preferred audio route for the speaker playback.

  • Represents the currently used microphone device.

    Remark

    This property is reflected identically to PlanetKitAudio.shared.micDevice.

    Declaration

    Swift

    @objc
    public var micDevice: PlanetKitAudioDevice? { get set }
  • Represents the currently used speaker device.

    Remark

    This property is reflected identically to PlanetKitAudio.shared.spkDevice.

    Declaration

    Swift

    @objc
    public var spkDevice: PlanetKitAudioDevice? { get set }

Setup Delegate

Play File

  • Plays a local audio file.

    Declaration

    Swift

    @objc
    public func playFile(fileResourceUrl: URL, type: String, loopCount: Int32 = -1)

    Parameters

    type

    Identifies a unique playing instance. Generally used to stop playing the audio file.

  • Plays a local audio file.

    Declaration

    Swift

    @objc
    public func playFile(fileResourceUrl: URL, type: String, loopCount: Int32, completion: @escaping (Bool) -> Void)

    Parameters

    type

    Identifies a unique playing instance. Generally used to stop playing the audio file.

    completion

    It is called after the audio file has finished playing.

  • Stops playing the audio file.

    Declaration

    Swift

    @objc
    public func playStop(type: String)