Using the Audio capture APIs

Before you begin, see Audio Functions.

A simple example for audio capture

<cfclientsettings enableDeviceAPI=true>

<cfclient>


<cfset opt = cfclient.audio.getOptions()> 
<cfset cfclient.audio.capture(opt,'func1')> 


<cffunction name="func1">
<cfargument name="mediaFileArray">
<cfset document.getElementById('result').innerHTML="<br>Value from callback function"> 
<cfset document.getElementById('result').innerHTML=document.getElementById('result').innerHTML+JSON.stringify(mediaFileArray)> 
<cfset document.getElementById('result').innerHTML=document.getElementById('result').innerHTML+mediaFileArray[1].fullPath>
</cffunction>

</cfclient>
<div id="result"/>

Record and play audio

<cfclient>
 
<cfset mediaFileArray=cfclient.audio.capture()> 

<cfset medFil=mediaFileArray[1].fullPath>
 
 
<!--- Play the media file --->
<cffunction name="playing">
<cfset medObj = cfclient.audio.play(medFil)>
</cffunction>
 
<!--- Pause the media --->
<cffunction name="pausing">
<cfset cfclient.audio.pause(medObj)>
</cffunction>
 
<!--- Release the media --->
<cffunction name="releasing">
<cfset cfclient.audio.release(medObj)>
</cffunction>
 
<!--- Stop the media --->
<cffunction name="stopping">
<cfset cfclient.audio.stop(medObj)>
</cffunction>
 
<!--- Get current position of the media file --->
<cffunction name="getcurpos">
<cfset pos = cfclient.audio.getCurrentPosition(medObj)>
</cffunction>

<!--- Go to a position in the media file --->
<cffunction name="seekingto">
<cftry>
<cfset pos = cfclient.audio.seekTo(medObj,2)>
<cfcatch type="any">
<cfset alert(cfcatch.message)>
</cfcatch>
</cftry>
</cffunction>
 
<!--- Start recording --->
<cffunction name="rec">
<cftry>
<cfset pos = cfclient.audio.record(medObj)>
<cfcatch type="any">
<cfset alert(cfcatch.message)>
</cfcatch> 
</cftry>
</cffunction>


<cffunction name="stoprec">
<cfset cfclient.audio.stopRecording(medObj)>
</cffunction>

</cfclient>

 Adobe

Get help faster and easier

New user?