AudioRecorder QML Type

High-level audio recording. More...

Import Statement: import ArcGIS.AppFramework.Multimedia 1.0

Properties

Signals

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.

NameValue
AudioRecorder.StoppedState0
AudioRecorder.RecordingState1
AudioRecorder.PausedState2

Status enumeration

This enum describes the possible recording states of the audio recorder. Informs the status property.

NameValue
AudioRecorder.UnavailableStatus0
AudioRecorder.UnloadedStatus1
AudioRecorder.LoadingStatus2
AudioRecorder.LoadedStatus3
AudioRecorder.StartingStatus4
AudioRecorder.RecordingStatus5
AudioRecorder.PausedStatus6
AudioRecorder.FinalizingStatus7

Error enumeration

Enum describing possible errors in the recording process. Informs the Error property.

NameValue
AudioRecorder.NoError0
AudioRecorder.ResourceError1
AudioRecorder.FormatError2
AudioRecorder.OutOfSpaceError3

EncodingQuality enumeration

Enum describing encoding quality levels. Informs the quality property.

NameValue
AudioRecorder.VeryLowQuality0
AudioRecorder.LowQuality1
AudioRecorder.NormalQuality2
AudioRecorder.HighQuality3
AudioRecorder.VeryHighQuality4

EncodingMode enumeration

Enum describing the available encoding modes. Informs the encodingMode property.

NameValue
AudioRecorder.ConstantQualityEncoding0
AudioRecorder.ConstantBitRateEncoding1
AudioRecorder.AverageBitRateEncoding2
AudioRecorder.TwoPassEncoding3

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.

NameValue
AudioRecorder.Available0
AudioRecorder.Unavailable1
AudioRecorder.Busy2
AudioRecorder.ResourceMissing3

Property Documentation

[read-only] actualLocation : url

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.


[read-only] availability : AvailabilityStatus

Returns the availability status of this functionality. Uses the AvailabilityStatus enum.


[read-only] available : bool

Returns true if audio recording is currently available. Otherwise, returns false.


[read-only] availableCodecs : object

Returns a list of available codecs.


[read-only] availableContainerFormats : object

Returns a list of available container formats.


[read-only] availableInputs : object

Returns a list of the name and description of all currently available audio input devices.


[read-only] availableSampleRates : object

Returns a list of available audio sample rates.


bitRate : int

Returns the bitrate audio is being recorded at. Read-only, and will change according to the quality level and sample rate.


channelCount : int

Returns the number of audio channels currently available.


codec : string

The codec currently being used. Uses the system default if not set.


[read-only] codecDescription : string

Returns a description of the codec currently in use.


containerFormat : string

The currently used container format.


[read-only] containerFormatDescription : string

Returns a description of the container format.


[read-only] continuousSampleRates : bool

Returns true if the given sample rate is continuous. Otherwise, returns false.


[read-only] defaultInput : string

Returns the name of the default audio input device.


[read-only] duration : int

Returns the current playback time of the audio file in milliseconds.


encodingMode : EncodingMode

The current encoding mode of the object. Uses the EncodingMode enum, and by default is set to NormalQuality.


[read-only] error : Error

Returns the code of the last error encountered. Uses the Error enum.


[read-only] errorString : string

Returns a human-readable string describing the last error that occurred.


input : string

Returns the input device for the audio recording. Uses the system default if not set otherwise.


[read-only] inputDescription : string

Returns a description of the current input device.


outputLocation : url

Sets the output location for the resulting audio file before the recording starts. If not set, uses the system default.


quality : EncodingQuality

Returns the level of quality the audio is recording at. Uses the EncodingQuality enum.


sampleRate : int

The sample rate of the recorder. If availableSampleRates has been set, it will attempt to match that number as closely as possible.


[read-only] state : State

Returns the current recording state. Uses the State enum, and by default is set to StoppedState.


[read-only] status : Status

Returns the current recording state of the object.


volume : double

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

actualLocationChanged(url location)

Signal emitted when the actual location of the audio file has been changed.

Note: The corresponding handler is onActualLocationChanged.


audioSettingsChanged()

Signal emitted when any audio settings, such as bitrate or codec, are changed.

Note: The corresponding handler is onAudioSettingsChanged.


availabilityChanged(AvailabilityStatus status)

Signal emitted when the availability status of this object has changed.

Note: The corresponding handler is onAvailabilityChanged.


availableChanged(bool available)

Signal emitted when the availability of recording audio has changed.

Note: The corresponding handler is onAvailableChanged.


durationChanged(int duration)

Signal emitted when the playback duration of the recording has changed.

Note: The corresponding handler is onDurationChanged.


errorChanged(Error error)

Signal emitted when the value denoting the latest error state has changed.

Note: The corresponding handler is onErrorChanged.


outputLocationChanged(url location)

Signal emitted when the output location of the resultant audio file has changed.

Note: The corresponding handler is onOutputLocationChanged.


stateChanged(State state)

Signal emitted when the audio recording state has changed.

Note: The corresponding handler is onStateChanged.


statusChanged(Status status)

Signal emitted when the recording state of the object has changed.

Note: The corresponding handler is onStatusChanged.


volumeChanged(double volume)

Signal emitted when the volume level has changed.

Note: The corresponding handler is onVolumeChanged.


Method Documentation

pause()

Pauses the audio recording. The status enum is changed to PausedStatus.


record()

Starts the audio recording. The status enum is changed to RecordingState.


stop()

Stops the audio recording. The state property is changed to StoppedState.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.