SoundControlKit (SCK) is a Swift package designed to simplify audio management in iOS applications. It provides an easy-to-use AudioManager for handling audio recording and playback.
The SCK package offers a convenient solution for managing audio-related tasks in your Swift projects. It includes functionalities for configuring the audio session, recording audio, playing audio, and controlling playback.
You can add SoundControlKit as a dependency in your Swift Package Manager-enabled project. Add the following to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/bilalBakhrom/SoundControlKit.git", from: "2.0.0")
]
To use SoundControlKit in your project, follow these steps:
import SoundControlKit
// Create an instance of `SCKAudioManager`.
let audioManager = SCKAudioManager()
// MARK: - Control Recording
// Start recording audio.
audioManager.configureRecorder()
audioManager.record()
// OR: Start recording audio with haptic vibration at the beginning.
Task { await audioManager.record() }
// Pause the recording.
audioManager.pauseRecording()
// Stop the recording.
audioManager.stopRecording()
// MARK: - Control Playback
// Play the recorded audio.
audioManager.play()
// Pause the playback.
audioManager.pausePlayback()
// Stop the playback.
audioManager.stopPlayback()
Control notifications:
// // Stop all ongoing audio playbacks.
NotificationCenter.default.post(sckNotification: .soundControlKitRequiredToStopAudioPlayback)
// Stop a specific audio playback with the specified `URL`.
NotificationCenter.default.post(sckNotification: .soundControlKitRequiredToStopAudioPlayback, object: recordingURL)
Explore the sample project that demonstrates how to use SoundControlKit.
SoundControlKit is released under the Apache License 2.0.
Explore the intricacies of audio recording with these informative articles: