mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Voice message recording enhancements (#2042)
* Use Combine to report AudioRecorder state changes * AudioRecorder is now using AVAudioEngine instead of AVAudioRecorder * Stop recording when audio configuration changes * AudioRecorder error handling * UnitTests * Use Accelerate to calculate RMS
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
enum VoiceMessageRecorderError: Error {
|
||||
@@ -21,17 +22,26 @@ enum VoiceMessageRecorderError: Error {
|
||||
case missingRecordingFile
|
||||
case previewNotAvailable
|
||||
case audioRecorderError(AudioRecorderError)
|
||||
case waveformAnalysisError
|
||||
case failedSendingVoiceMessage
|
||||
}
|
||||
|
||||
enum VoiceMessageRecorderAction {
|
||||
case didStartRecording(audioRecorder: AudioRecorderProtocol)
|
||||
case didStopRecording(previewState: AudioPlayerState, url: URL)
|
||||
case didFailWithError(error: VoiceMessageRecorderError)
|
||||
}
|
||||
|
||||
protocol VoiceMessageRecorderProtocol {
|
||||
var audioRecorder: AudioRecorderProtocol { get }
|
||||
var previewAudioPlayerState: AudioPlayerState? { get }
|
||||
var recordingURL: URL? { get }
|
||||
var recordingDuration: TimeInterval { get }
|
||||
|
||||
func startRecording() async -> Result<Void, VoiceMessageRecorderError>
|
||||
func stopRecording() async -> Result<Void, VoiceMessageRecorderError>
|
||||
|
||||
var actions: AnyPublisher<VoiceMessageRecorderAction, Never> { get }
|
||||
|
||||
func startRecording() async
|
||||
func stopRecording() async
|
||||
func cancelRecording() async
|
||||
func startPlayback() async -> Result<Void, VoiceMessageRecorderError>
|
||||
func pausePlayback()
|
||||
|
||||
Reference in New Issue
Block a user