Audio Capture API の使用

警告 :

すべてのモバイル機能とモバイル関連機能は ColdFusion(2025リリース)で削除されました。

詳しくは、ColdFusion の非推奨の機能を参照してください。

開始する前に、オーディオ関数を参照してください。

オーディオキャプチャの簡単な例

<cfclientsettings enableDeviceAPI=true>

<cfclient>


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


<cffunction name=&quot;func1&quot;>
<cfargument name=&quot;mediaFileArray&quot;>
<cfset document.getElementById('result').innerHTML=&quot;<br>Value from callback function&quot;> 
<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=&quot;result&quot;/>

オーディオの録音と再生

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

<cfset medFil=mediaFileArray[1].fullPath>
 
 
<!--- メディアファイルを再生します --->
<cffunction name=&quot;playing&quot;>
<cfset medObj = cfclient.audio.play(medFil)>
</cffunction>
 
<!--- メディアを一時停止します --->
<cffunction name=&quot;pausing&quot;>
<cfset cfclient.audio.pause(medObj)>
</cffunction>
 
<!--- メディアをリリースします --->
<cffunction name=&quot;releasing&quot;>
<cfset cfclient.audio.release(medObj)>
</cffunction>
 
<!--- メディアを停止します --->
<cffunction name=&quot;stopping&quot;>
<cfset cfclient.audio.stop(medObj)>
</cffunction>
 
<!--- メディアファイルの現在の位置を取得します --->
<cffunction name=&quot;getcurpos&quot;>
<cfset pos = cfclient.audio.getCurrentPosition(medObj)>
</cffunction>

<!--- メディアファイルの位置に移動します --->
<cffunction name=&quot;seekingto&quot;>
<cftry>
<cfset pos = cfclient.audio.seekTo(medObj,2)>
<cfcatch type=&quot;any&quot;>
<cfset alert(cfcatch.message)>
</cfcatch>
</cftry>
</cffunction>
 
<!--- 録音を開始します --->
<cffunction name=&quot;rec&quot;>
<cftry>
<cfset pos = cfclient.audio.record(medObj)>
<cfcatch type=&quot;any&quot;>
<cfset alert(cfcatch.message)>
</cfcatch> 
</cftry>
</cffunction>


<cffunction name=&quot;stoprec&quot;>
<cfset cfclient.audio.stopRecording(medObj)>
</cffunction>

</cfclient>

ヘルプをすばやく簡単に入手

新規ユーザーの場合