Supported audio Functions

http://docs.phonegap.com/en/2.5.0/cordova_media_capture_capture.md.html#CaptureAudioOptions

 

API

Description

Returns

Parameters

 

 

capture([options],
[callback])

 

Record audio based on provided options

Array of MediaFile object or null based on whether callback function is provided or not

options (Audio Options, callBack) 

The audio options are listed here.

 

 

createMedia(src,
[statusCallback])

 

Create media object for playback

Media Object

src fullpath of media file

 

statusCallback function to get Media Playback status events  

 

 

getCurrentPosition(media)

 

Get current position for given media object

position (Number)

Media Object  

 

 

play(src)

 

Start or resume given audio file

Media object

fullpath or Media Object  

 

 

pause(media)

 

Pause given audio file

void

Media Object  

 

 

release(media)

 

Release underlying audio resources

void

Media Object  

 

 

seekTo(media, duration)

 

Set current position within audio file

void

Media Object

duration in milliseconds  

 

 

stop(media)

 

Stop playing given audio file

void

Media Object  

 

 

record(media)

 

Record to file

void

Media Object  

 

 

stopRecording(media)

 

Stop recording to given audio file

void

Media Object

Recording audio

<!--- using callback function --->
<cfset cfclient.audio.capture({},recordingComplete) >

<cffunction name="recordingComplete" >
<cfargument name="mediafile" />
<!---Populating the content of the <div> with the ID divId-->
<cfset document.getElementById('divId').innerHTML =
mediafile[1].fullPath>
<cfset document.getElementById('divId'). innerHTML = mediafile.size>

</cffunction>

<!--- without callback function --->
<cfset mediafile = cfclient.audio.capture() >
<cfset document.getElementById('divId').innerHTML =
mediafile[1].fullPath>
<cfset document.getElementById('divId'). innerHTML = mediafile.size>

Note: The duration parameter of audio options is not supported on Android. The Mode parameter is not supported on both platforms.

Playing audio

<!--- playing file from a given source --->
<cfset media = cfclient.audio.createMedia("/mnt/sdcard/myaudiofile.wav") >

<cfset cfclient.audio.play(media) >
<cfset cfclient.audio.pause(media) >
<cfset cfclient.audio.stop(media) >
<cfset cfclient.audio.release(media) >

More examples

See Using the Audio capture APIs.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy