Audio Functions

Supported audio Functions

 

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) 

 

 

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.

Логотип Adobe

Увійдіть до облікового запису