AudioRecorder external object

Official Content
This documentation is valid for:

The AudioRecoder external object is a simple API that helps you record and save audio as a file.

Audioexternalobject-Location_png image_2018612135630_1_png


IsRecording property

Indicates whether the device is currently recording (True) or not (False).


Note: This API defines two methods to be called in batch mode (no UI is presented to the user).

Start method

Starts an audio recording session and returns whether the operation was successful or not (e.g. if there is another recording in progress, it will return False). The audio recorded will be saved to a local file. The recorded file path is returned by the Stop method (see bellow), and it can be assigned to an Audio-based attribute or variable.

Return value Boolean
Parameters None

Stop method

Stops the current audio recording session and returns the file path where the audio file was saved. Multiple calls to this method do not have any effect.

Return value URL
Parameters None


It does not have any.


Note: This sample does not include details on how to handle the UI customization aspects.

Suppose a simple scenario of a community chat. Nowadays, every messaging system has two main components:

  1. Every message is shown from the bottom of the screen to the top. This can be achieved by using the Inverse Loading property at the grid level.
  2. There is a text-field where the end users can write their text messages and then send them by tapping a button on the screen. This can be achieved by including a variable based on the Character data type and a Button control with the following behavior:
Event 'SendTextMessage'

Basically, the SendTextMessage procedure receives the message to send (&Text variable, it must be inout) and the username (&Username variable), performs the necessary checks and then sends the message and cleans the &Text variable.

Now suppose we want to incorporate a third component: the ability to send audio messages.

There are two things we need to do to implement this feature.

  • Record the audio message
    It can be done by including a button that starts the recording process and notifies the user in case the recording session could not be started.
Event 'StartRecording'
     &HasSuccess = AudioRecorder.Start()
     If not &HasSuccess
       msg("For some reason we couldn't start recording")

This button should be hidden once the operation is completed successfully, and another button should be displayed to stop the current recording process (as it is described in the following point).

  • Send the audio message recorded
    Once the end user stops recording, the current audio message will be sent.
Event 'StopRecording'
     &IsRecording = AudioRecorder.IsRecording
     If &IsRecording
       &FilePath = AudioRecorder.Stop()
       &Audio.AudioURI = &FilePath

The SendAudioMessage procedure is analogous to the SendTextMessage procedure. Remember that this button was shown once the end user taps on the 'StartRecording' button. For that reason, it is not possible that the 'StopRecording' event has been called without having started a recording previously. Nevertheless, in this case, we prefer to include a validation step to avoid the problem of sending an empty audio message (because the Stop method does not have effect when there is not an audio recording). Also, to be consistent, the developer must hide this button if the operation was successful and must display the button that allows the end user to start a new recording.

After applying these concepts and by adding a friendly custom UI, a developer can achieve the following results.

AudioRecorder - Sample


  • The audio file will be saved as MPEG-4 format with AAC encoder. This format is compatible with all the supported platforms.
  • If the application is closed while there is an active audio recording session, then the recording is stopped and the audio file is discarded.
  • The recorded audio can be played using the methods of the Audio external object.


Platforms SmartDevices(iOS, Android)


This external object is available as from GeneXus 15 Upgrade 4.

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.