The Avaudiorecorder class is dedicated to handling recording operations and can provide audio recording capabilities in your application. Recordings can only be saved to local files. It is included in the Avfoundation Framework library.
The following are common properties and methods:
Property |
Description |
@property (readonly, getter=isrecording) BOOL recording |
Whether audio is being recorded (read-only) |
@property (readonly) Nsurl *url |
Audio file path (read only) |
@property (nonatomic, copy) Nsarray *channelassignments |
An array of Avaudiosessionchanneldescription objects associated with the recorder |
@property (readonly) Nstimeinterval currenttime |
Recording duration (read only), can only be used when recording, when the recording stops, straight to 0 |
@property (readonly) Nstimeinterval Devicecurrenttime |
Enter the length of the setting, read-only, and note that this property is accessible all the time |
@property (readonly) nsdictionary *settings |
Audio settings for audio recorders. (Read only) |
@property (getter=ismeteringenabled) BOOL meteringenabled |
Whether to enable recording measurement, if you enable recording measurement can obtain data such as decibel recording |
Method |
Description |
-(Instancetype) Initwithurl: (nsurl *) URL settings: (nsdictionary *) settings error: (Nserror *) outerror |
How to initialize the Sound Recorder object, the URL must be a local file URL |
-(BOOL) Preparetorecord |
Preparing recordings, primarily for creating caches |
-(BOOL) record |
Start recording |
-(BOOL) Recordattime: (nstimeinterval) time |
Start recording at a specified time, |
-(BOOL) Recordforduration: (nstimeinterval) duration |
Start recording according to the specified length of time |
-(BOOL) Recordattime: (nstimeinterval) Time forduration: (nstimeinterval) duration |
Start recording at a specified time and specify the length of the recording |
-(void) Pause |
Pause Recording |
-(void) stop |
Stop Recording |
-(BOOL) deleterecording |
Delete the recording, note that the recorder must be in a stopped state at this time |
Proxy method |
Description |
-(void) audiorecorderdidfinishrecording: (Avaudiorecorder *) Recorder successfully: (BOOL) flag |
End of recording |
-(void) Audiorecorderencodeerrordidoccur: (Avaudiorecorder *) Recorder error: (NSERROR *) error |
Audio Codec error occurred |
When you create a sound recorder, you must specify the recording settings information in addition to the path, because the recorder must know the format of the recording file, the sample rate, the number of channels, and so on.
Avaudiorecorder Recording Processing