|Type||Topic||Plugin||Version||macOS||Windows||Linux||Console & Web||iOS|
|class||AVFoundation||MBS AVFoundation Plugin||13.2||Yes||No||No||Yes, macOS only||No|
dim f as FolderItem = SpecialFolder.Desktop.Child("test.caf")
dim recordSetting as new Dictionary
dim n as Integer = OSTypeFromStringMBS(AVFoundationMBS.kAudioFormatLinearPCM)
recordSetting.Value(AVFoundationMBS.AVFormatIDKey) = n
recordSetting.Value(AVFoundationMBS.AVSampleRateKey) = 44100.0
recordSetting.Value(AVFoundationMBS.AVNumberOfChannelsKey) = 2
recordSetting.Value(AVFoundationMBS.AVLinearPCMBitDepthKey) = 16
recordSetting.Value(AVFoundationMBS.AVLinearPCMIsBigEndianKey) = false
recordSetting.Value(AVFoundationMBS.AVLinearPCMIsFloatKey) = false
dim error as NSErrorMBS
dim recorder as new AVAudioRecorderMBS(f, recordSetting, error)
if error<>Nil then
if recorder.recordForDuration(10) then
MsgBox "Failed to start recording."
Using an audio recorder you can:
- Record until the user stops the recording
- Record for a specified duration
- Pause and resume a recording
- Obtain input audio-level data that you can use to provide level metering
In OS X, the audio comes from the system's default audio input device as set by a user in System Preferences.
You can implement a subclass of AVFoundationMBS to respond to audio interruptions and audio decoding errors, and to the completion of a recording.
To configure a recording, including options such as bit depth, bit rate, and sample rate conversion quality, configure the audio recorder's settings dictionary. Use the settings keys described in AV Foundation Audio Settings Constants.
To configure an appropriate audio session for recording, refer to AVAudioSession Class Reference and AVAudioSessionDelegate Protocol Reference.
The AVAudioRecorder class is intended to allow you to make audio recordings with very little programming overhead. Other classes that can be used for recording audio in OS X include AVCaptureAudioDataOutput and the Audio Queue services described in the Audio Queue Services Programming Guide.
In OS X, you can also use the AVCaptureAudioFileOutput class to record audio.
Available in OS X v10.7 and later.
Calls audioRecorderEncodeErrorDidOccur and audioRecorderDidFinishRecording events on AVFoundationMBS class.
- 2 properties
- 15 methods
- method averagePowerForChannel(channelNumber as Integer) as Double
- method Constructor(file as folderitem, settings as Dictionary, byref error as NSErrorMBS)
- method Constructor(URL as string, settings as Dictionary, byref error as NSErrorMBS)
- method currentTime as Double
- method deleteRecording as boolean
- method pause
- method peakPowerForChannel(channelNumber as Integer) as Double
- method prepareToRecord as boolean
- method record as boolean
- method recordForDuration(duration as Double) as boolean
- method Recording as boolean
- method settings as Dictionary
- method stop
- method updateMeters
- method url as string
- shared method available as boolean
This class has no sub classes.
Some events for this class:
- AVFoundationMBS.audioRecorderDidFinishRecording(recorder as AVAudioRecorderMBS, successful as boolean)
- AVFoundationMBS.audioRecorderEncodeErrorDidOccur(recorder as AVAudioRecorderMBS, error as NSErrorMBS)
Some examples which use this class:
The items on this page are in the following plugins: MBS AVFoundation Plugin.
MBS FileMaker Plugins