addListener


Purpose

Registers a listener for Media Audio events.

Signature

Audio.addListener( callbacks )

Returns

This method does not return anything.

Parameter

Name Description Type Use
callbacks Passed to process the events. object required

Callback structure

The callback object can be structured as follows:

{
  onPlayed: function( )  { ... },
  onRecorded: function( payload )  { ... },
  onStopped: function( payload )  { ... },
  onPaused: function( payload ) { ... },
  onFailure: function( error ) { ... }
}

Methods

Name Description Return type
onPlayed Called if audio playback finished successfully. undefined
onRecorded

Called if audio recording finished successfully.

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
onStopped

Called if audio playing or recording stopped successfully.

The method's session object informs of the type of operation that has been stopped. Possible session types are listed in the Constants table, in the Media article.

undefined
onPaused

Called if audio playing or recording paused successfully.

The method's session object informs of the type of operation that has been paused. Possible session types are listed in the Constants table, in the Media article.

Note

Pausing the recording is available on iOS only.

undefined
onFailure

Called if an error occurs. It passes the following object:

{ code, description }

Possible failure types are listed in the Constants table, in the Media article.

undefined

Related topics

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