High-level audio recording. More...
Import Statement: | import ArcGIS.AppFramework.Multimedia 1.0 |
Properties
- actualLocation : url
- availability : AvailabilityStatus
- available : bool
- availableCodecs : object
- availableContainerFormats : object
- availableInputs : object
- availableSampleRates : object
- bitRate : int
- channelCount : int
- codec : string
- codecDescription : string
- containerFormat : string
- containerFormatDescription : string
- continuousSampleRates : bool
- defaultInput : string
- duration : int
- encodingMode : EncodingMode
- error : Error
- errorString : string
- input : string
- inputDescription : string
- outputLocation : url
- quality : EncodingQuality
- sampleRate : int
- state : State
- status : Status
- volume : double
Signals
- actualLocationChanged(url location)
- audioSettingsChanged()
- availabilityChanged(AvailabilityStatus status)
- availableChanged(bool available)
- durationChanged(int duration)
- errorChanged(Error error)
- outputLocationChanged(url location)
- stateChanged(State state)
- statusChanged(Status status)
- volumeChanged(double volume)
Methods
Detailed Description
The AudioRecorder component is a high level media recording component, as well as providing tools to select the audio input and control the quality of the output.
This code sample provides a simple control panel for recording audio, with buttons to start recording, pause, stop the recording, define the file's output location, and play back the result.
This code sample demonstrates the usage of AudioRecorder, providing an control panel for the recording and playback of audio. In addition to the AppFramework.Multimedia plugin, this sample also requires the QtQuickDialogs, QtMultimedia, and QtQuickLayouts plugins to run.
Item { RowLayout { Layout.fillWidth: true Button { text: "Record" enabled: audioRecorder.available onClicked: audioRecorder.record(); } Button { text: audioRecorder.state == AudioRecorder.PausedState ? "Unpause" : "Pause" enabled: audioRecorder.state == AudioRecorder.RecordingState onClicked: { if (audioRecorder.state == AudioRecorder.PausedState) { audioRecorder.record(); } else { audioRecorder.pause(); } } } Button { text: "Stop" enabled: audioRecorder.state == AudioRecorder.RecordingState || audioRecorder.state == AudioRecorder.PausedState onClicked: audioRecorder.stop(); } Button { text: "Location" enabled: audioRecorder.state == AudioRecorder.StoppedState onClicked: outputDialog.open(); } Button { text: "Play" enabled: audioRecorder.state == AudioRecorder.StoppedState && audioRecorder.actualLocation > "" && audioRecorder.duration > 0 onClicked: { audio.source = audioRecorder.actualLocation; audio.play(); } } } AudioRecorder { id: audioRecorder onStatusChanged: { console.log("audioRecorder status:", status); } onErrorChanged: { console.log("audioRecorder error:", error, "errorString:", errorString); } } Audio { id: audio } FileDialog { id: outputDialog title: "Output Location" selectExisting: false selectMultiple: false nameFilters: [ "All files (*)" ] folder: AppFramework.standardPaths.standardLocations(StandardPaths.MusicLocation)[0] onAccepted: { audioRecorder.outputLocation = fileUrl; } } }
Enumerations
State enumeration
Enum describing the current state of the recording device. Informs the state property.
Name | Value |
---|---|
AudioRecorder.StoppedState | 0 |
AudioRecorder.RecordingState | 1 |
AudioRecorder.PausedState | 2 |
Status enumeration
This enum describes the possible recording states of the audio recorder. Informs the status property.
Name | Value |
---|---|
AudioRecorder.UnavailableStatus | 0 |
AudioRecorder.UnloadedStatus | 1 |
AudioRecorder.LoadingStatus | 2 |
AudioRecorder.LoadedStatus | 3 |
AudioRecorder.StartingStatus | 4 |
AudioRecorder.RecordingStatus | 5 |
AudioRecorder.PausedStatus | 6 |
AudioRecorder.FinalizingStatus | 7 |
Error enumeration
Enum describing possible errors in the recording process. Informs the Error property.
Name | Value |
---|---|
AudioRecorder.NoError | 0 |
AudioRecorder.ResourceError | 1 |
AudioRecorder.FormatError | 2 |
AudioRecorder.OutOfSpaceError | 3 |
EncodingQuality enumeration
Enum describing encoding quality levels. Informs the quality property.
Name | Value |
---|---|
AudioRecorder.VeryLowQuality | 0 |
AudioRecorder.LowQuality | 1 |
AudioRecorder.NormalQuality | 2 |
AudioRecorder.HighQuality | 3 |
AudioRecorder.VeryHighQuality | 4 |
EncodingMode enumeration
Enum describing the available encoding modes. Informs the encodingMode property.
Name | Value |
---|---|
AudioRecorder.ConstantQualityEncoding | 0 |
AudioRecorder.ConstantBitRateEncoding | 1 |
AudioRecorder.AverageBitRateEncoding | 2 |
AudioRecorder.TwoPassEncoding | 3 |
AvailabilityStatus enumeration
Enum describing service availability status errors. Informs the availability property.
Availabile indicates that the service is operating correctly and can be used. Unavailable indicates that no service is available to perform the requested functionality. ResourceMissing indicates the service is unable to allocate the resources required to function correctly. Busy indicates the service is currently unable to access the necessary resources, and will need to wait.
Name | Value |
---|---|
AudioRecorder.Available | 0 |
AudioRecorder.Unavailable | 1 |
AudioRecorder.Busy | 2 |
AudioRecorder.ResourceMissing | 3 |
Property Documentation
This property holds the actual location of the last media content. This location is usually available after recording starts, and reset when a new location is set or a new recording starts.
Returns the availability status of this functionality. Uses the AvailabilityStatus enum.
Returns true if audio recording is currently available. Otherwise, returns false.
Returns a list of the name and description of all currently available audio input devices.
Returns the bitrate audio is being recorded at. Read-only, and will change according to the quality level and sample rate.
Returns true if the given sample rate is continuous. Otherwise, returns false.
The current encoding mode of the object. Uses the EncodingMode enum, and by default is set to NormalQuality.
Returns a human-readable string describing the last error that occurred.
Returns the input device for the audio recording. Uses the system default if not set otherwise.
Sets the output location for the resulting audio file before the recording starts. If not set, uses the system default.
Returns the level of quality the audio is recording at. Uses the EncodingQuality enum.
The sample rate of the recorder. If availableSampleRates has been set, it will attempt to match that number as closely as possible.
Returns the current recording state. Uses the State enum, and by default is set to StoppedState.
The current volume level of the app. This is represented as a value between 0 and 1, with the default being 1 (full volume).
Signal Documentation
Signal emitted when the actual location of the audio file has been changed.
Note: The corresponding handler is onActualLocationChanged
.
Signal emitted when any audio settings, such as bitrate or codec, are changed.
Note: The corresponding handler is onAudioSettingsChanged
.
Signal emitted when the availability status of this object has changed.
Note: The corresponding handler is onAvailabilityChanged
.
Signal emitted when the availability of recording audio has changed.
Note: The corresponding handler is onAvailableChanged
.
Signal emitted when the playback duration of the recording has changed.
Note: The corresponding handler is onDurationChanged
.
Signal emitted when the value denoting the latest error state has changed.
Note: The corresponding handler is onErrorChanged
.
Signal emitted when the output location of the resultant audio file has changed.
Note: The corresponding handler is onOutputLocationChanged
.
Signal emitted when the audio recording state has changed.
Note: The corresponding handler is onStateChanged
.
Signal emitted when the recording state of the object has changed.
Note: The corresponding handler is onStatusChanged
.
Signal emitted when the volume level has changed.
Note: The corresponding handler is onVolumeChanged
.