getAudio


Purpose

Picks audio data from the library or the recorder.

Note

This method is supported on Android devices only.

Signature

getAudio( output, options, callbacks )

Returns

This method does not return anything.

Parameters

Name Description Type Use
output

Passed to set the output configuration. It can be structured as follows:

{
 saveToFile,
 saveToData
}

Please see the table below for details.

object required
options

Passed to set the configuration for the audio file. Default values will be used if the object is empty. It can be structured as follows:

{
 sourceType,
 url
}

Please see the table below for details.

object required
callbacks

Passed to verify whether the devce was able to capture any audio. It can be structured as follows:

{
  onSuccess: function(success) {...},
  onCancel: function() {...},
  onFailure: function(error) {...}
}

object required

The table below lists parameters passed via the output object.

Parameter Description Type
saveToFile

Saves to FileEntry URL or a temporary File API URL if the "url" setting is not specified in the options object. By default it is set to "true".

Boolean
saveToData Indicates whether to return a Data URL or not. By default it is set to "false". Boolean

The table below lists parameters passed via the options object.

Parameter Description Type
sourceType Source of audio data. Possible source types are listed in the Constants table of the Media article. The default setting is USER_CHOICE. It displays a native picker that allows to select either a built-in voice recorder application or the audio roll. String
url A URL address obtained from the FileEntry object by calling the toURL method. If not provided, a URL address of the temporary storage is generated. String

The table below lists all callbacks supported by the method.

Name Description Return type
onSuccess

Called when the function finishes without an error.

The method's object consists of the following fields:

  • url - A File API URL address, returned if the saveToFile parameter was set to "true".

  • size - Audio size in bytes.

  • duration - Duration of the audio in milliseconds.

  • data - A Data URL, returned if the saveToData parameter was set to "true".

undefined
onCancel Called when the user cancels picking or recording an audio. undefined
onFailure

Called when an error occurs.

The error object contains the description field - a human-readable error description.

undefined

Related topics

Media
Legal notice | Copyright © 2015 and Confidential to Pegasystems Inc. All rights reserved. | Feedback
Advanced...