Package | Top Level |
Class | public class AudioRecorder4JS |
Inheritance | AudioRecorder4JS ![]() |
AudioRecorder4JS is a wrapper of ASSDK for JavaScript. AudioRecorder4JS registers methods, which JavaScript can call, using "ExternalInterface.addCallback" AudioRecorder4JS call's JavaScript callbacks through "ExternalInterface.call"
AudioRecorder4JS exposes the following methods for JS
// recorder methods startRecord stopRecord startReplay stopReplay // connection methods reconnect // core requester methods requestSpeechCore // Microphone panel methods showVolumeBar hideVolumeBar unHideAll hideAll // AudioRecorder4JS properties getter ans setter getRecordTime getState getMicStatus getRecorderStatus getConnectorStatus getCoreRequesterStatus adjustNotifyAudioVolume getNotifyAudioVolume adjustReplayAudioVolume getReplayAudioVolume adjustMicVolume getMicVolume
Each JavaScript callback has the following signature:
callback(statusCode, returnStr)
where, statusCode is a String, while returnStr is a JSON String. See AudioiRecorder4JS constructor for details.
See also
Method | Defined By | ||
---|---|---|---|
AudioRecorder4JS accecpt initialising parameter from FlashVars
Full FlashVars
{
// AISpeech API account
"appKey": "your app key",
"secretKey": "your secret key",
// Log settings
"logId":"logId", empty logId usually means using no JSSDK
"userId":
"as2sdkVersion": "2.1.1", empty as2sdkVersion usually means using no AS2SDK
"logLevel": ["DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL"], default: refer to this._logLevel,
"logTarget": [1 | 2 | 3] (1:JS_ARTHROPOD, 2:ARTHROPOD, 3:NO_LOG), default: refer to this._logTarget,
// microphone setting
"encodingType": "NellyMoser",
// Microphone panel settings
"showFlash": ["true" | "false"],
"backgroundColor": "0xffffff",
"language": ["en" | "zh-CN"],
// API service settings
"connectLocalService": ["true" | "false"], default: true
"urlListServiceUrl": defaut: URLListFactory.URLLIST_SERVICE_URL
"logServiceUrl": default: ASSDKLogBase.LOG_SERVICE_URL
"defaultAPIServiceUrlArray": default: ConnectionFactory.DEFAULT_API_SERVICE_ARRAY
"localServiceUrl": default: ConnectionFactory.LOCAL_SERVICE_URL
"latencyCheckServiceApplication": ":5080/v2.0/latencydetect", default: LatencyCheck.LATENCY_CHECK_APPLICATION
// core requester settings
"coreTimeout": "5000",
// swf initialisation setting
"delayInitTime", default 500 (ms)
// JS callbacks
"errorEventHandler": "aispeech.AiRecorder.cache.recorderOnError",
"coreRequesterEventHandler": "aispeech.AiRecorder.cache.recorderOnScoreCallback",
"connectorEventHandler": "aispeech.AiRecorder.cache.recorderOnConnectorStatusChange",
"flashLoadEventHandler": "aispeech.AiRecorder.cache.recorderOnFlashLoad",
"factoryEventHandler": "aispeech.AiRecorder.cache.recorderOnFactoryStateChange",
"recorderEventHandler": "aispeech.AiRecorder.cache.recorderOnRecorderStateChange",
"micEventHandler": "aispeech.AiRecorder.cache.recorderonMicStatusChange",
"jsLogCallback": "jsLog"
}
| AudioRecorder4JS | ||
adjustMicVolume(value:Number):void
set mic volume (gain)
| AudioRecorder4JS | ||
adjustNotifyAudioVolume(value:Number):void
set Ding volume
| AudioRecorder4JS | ||
adjustReplayAudioVolume(value:Number):void
set replay volume
| AudioRecorder4JS | ||
CoreRequestStatus():String
get the core requester state
| AudioRecorder4JS | ||
disconnect():void
disconnect
| AudioRecorder4JS | ||
getConnectStatus():String
get the connection state
| AudioRecorder4JS | ||
getMicStatus():String
get the mic status
| AudioRecorder4JS | ||
getMicVolume():Number
get mic volume (gain)
| AudioRecorder4JS | ||
getNotifyAudioVolume():Number
get Ding volume
| AudioRecorder4JS | ||
getRecorderStatus():String
get the recorder status
| AudioRecorder4JS | ||
getRecordTime():uint
TODO
| AudioRecorder4JS | ||
getReplayAudioVolume():Number
get replay volume
| AudioRecorder4JS | ||
getState():Object | AudioRecorder4JS | ||
hideAll():void
Hide microphone panel
| AudioRecorder4JS | ||
hideVolumeViewer():void | AudioRecorder4JS | ||
reconnect():void
reconnect
| AudioRecorder4JS | ||
requestSpeechCore(params:Object):void
TODO: direct method call from javascript;
| AudioRecorder4JS | ||
setMicrophoneLoopback(isLoopback:Boolean):void | AudioRecorder4JS | ||
showVolumeViewer(params:Object = null, barNum:int = 49):void | AudioRecorder4JS | ||
startRecord(param:Object):String
Start record
| AudioRecorder4JS | ||
startReplay(param:Object):String
Start replay
| AudioRecorder4JS | ||
stopRecord(param:Object):String
Stop record
| AudioRecorder4JS | ||
stopReplay(param:Object):String
Stop replay
| AudioRecorder4JS | ||
unHideAll():void
Show microphone panel
| AudioRecorder4JS |
Method | Defined By | ||
---|---|---|---|
assignJSCallbacks(paramObj:Object):void
AudioRecorder4JS suppport the following JS callbacks, as long as they are given
flashLoadEventHandler
connectorEventHandler
coreRequesterEventHandler
micEventHandler
recorderEventHandler
factoryEventHandler
errorEventHandler
| AudioRecorder4JS | ||
coreRequesterEventHandler(event:CoreRequesterEvent):void
CoreRequesterEvent.RESULT
callback: coreRequesterEventHandler
status code: StatusCode.CORE_REQUEST_GETTED
message: core results
CoreRequesterEvent.EXCEPTION_TIMEOUT
callback: errorEventHandler
status code: StatusCode.CORE_REQUEST_TIMEOUT
message: {recordId:}
CoreRequesterEvent.EXCEPTION_PARAMETERS_ERROR
callback: errorEventHandler
status code: StatusCode.CORE_REQUEST_ERROR
message: empty
CoreRequesterEvent.EXCEPTION_RESPONSE_ERROR
callback: errorEventHandler
status code: StatusCode.CORE_REQUEST_ERROR
message: response data
| AudioRecorder4JS | ||
factoryEventHandler(event:FactoryEvent):void
FactoryEvent.READY
callback: factoryEventHandler
status code: StatusCode.DEPENDENCY_READY
message: {sessionId:}
FactoryEvent.EXCEPTION_TIMEOUT
callback: factoryEventHandler
status code: StatusCode.EXCEPTION_FACTORY_TIMEOUT
message: empty
FactoryEvent.EXCEPTION_MAXIMUM_RECONNECT
callback: factoryEventHandler
status code: StatusCode.EXCEPTION_FACTORY_MAXIUM_RECONNECT
message: empty
| AudioRecorder4JS | ||
initRecorder(paramObj:Object):void
AudioRecorder4JS listens to the following ASSDK events
FactoryEvent.READY
FactoryEvent.EXCEPTION_TIMEOUT
NetEvent.EXCEPTION_CLOSED
CoreRequesterEvent.RESULT
CoreRequesterEvent.EXCEPTION_TIMEOUT
CoreRequesterEvent.EXCEPTION_PARAMETERS_ERROR
CoreRequesterEvent.EXCEPTION_RESPONSE_ERROR
MicrophoneDeviceEvent.MIC_ALLOWED
MicrophoneDeviceEvent.EXCEPTION_MIC_NOT_ALLOWED
MicrophoneDeviceEvent.EXCEPTION_MIC_NOT_FOUND
MicrophoneDeviceEvent.EXCEPTION_MMSCFG_SETTING
MicrophoneVolumeSliderEvent.VOLUME_CHANGED
RecorderEvent.RECORD_STOPPED
RecorderEvent.RECORD_STARTED
RecorderEvent.REPLAY_STOPPED
RecorderEvent.REPLAY_STARTED
RecorderEvent.EXCEPTION_NO_RECORD
RecorderEvent.RECORDID_GOT
| AudioRecorder4JS | ||
microphoneDeviceEventHandler(event:MicrophoneDeviceEvent):void
MicrophoneDeviceEvent.MIC_ALLOWED
callback: micEventHandler
status code: StatusCode.MIC_UNMUTED
message: empty
MicrophoneDeviceEvent.EXCEPTION_MIC_NOT_ALLOWED
callback: micEventHandler
status code: StatusCode.MIC_MUTED
message: empty
MicrophoneDeviceEvent.EXCEPTION_MIC_NOT_FOUND
callback: micEventHandler
status code: StatusCode.EXCEPTION_MIC_NOT_AVAILABLE
message: empty
MicrophoneDeviceEvent.EXCEPTION_MMSCFG_SETTING
callback: micEventHandler
status code: StatusCode.EXCEPTION_MMSCFG_SETTING
message: empty
| AudioRecorder4JS | ||
MicrophoneVolumeSliderEvent.VOLUME_CHANGED
callback: recorderEventHandler
status code: StatusCode.RECORD_MICROPHONE_GAN_CHANGED
message: {gan:}
| AudioRecorder4JS | ||
netEventHandler(event:NetEvent):void
NetEvent.EXCEPTION_CLOSED
callback: connectorEventHandler
status code: StatusCode.FMS_CONNECT_CLOSED
message: empty
| AudioRecorder4JS | ||
recorderEventHandler(event:RecorderEvent):void
RecorderEvent.RECORD_STOPPED
callback: recorderEventHandler
status code: StatusCode.RECORD_STOP
message:{stopType:}
RecorderEvent.RECORD_STARTED
callback: recorderEventHandler
status code: StatusCode.RECORD_START
message: {recordId:}
RecorderEvent.REPLAY_STOPPED
callback: recorderEventHandler
status code: StatusCode.REPLAY_STOP
message: {stopType:}
RecorderEvent.REPLAY_STARTED
callback: recorderEventHandler
status code: StatusCode.REPLAY_START
message: {recordId:}
RecorderEvent.EXCEPTION_NO_RECORD
callback: recorderEventHandler
status code: StatusCode.EXCEPTION_NO_RECORD
message: {recordId:}
RecorderEvent.RECORDID_GOT
callback: recorderEventHandler
status code: StatusCode.RECORDID_GETTED
message: {recordId:}
| AudioRecorder4JS | ||
returnCallBack(callBack:String, statusCode:String, param:Object = null):void
Make JS callbacks
Note that, JSON String escapes the following characters: %, \, ", and amp (ASDoc does not parse amp character neither...)
text = text.split("%").join("%25")
.split("\\").join("%5c")
.split("\"").join("%22")
.split("amp").join("%26");
JS side should do reverting before processing message
text = text.replace(/%22/g, "\"")
.replace(/%5c/g, "\\")
.replace(/%26/g, "amp")
.replace(/%25/g, "%");
| AudioRecorder4JS |
AudioRecorder4JS | () | Constructor |
public function AudioRecorder4JS()
AudioRecorder4JS accecpt initialising parameter from FlashVars
Full FlashVars
adjustMicVolume | () | method |
public function adjustMicVolume(value:Number):void
set mic volume (gain)
Parameters
value:Number — 0-100
|
adjustNotifyAudioVolume | () | method |
public function adjustNotifyAudioVolume(value:Number):void
set Ding volume
Parameters
value:Number — 0-100
|
adjustReplayAudioVolume | () | method |
public function adjustReplayAudioVolume(value:Number):void
set replay volume
Parameters
value:Number — 0-100
|
assignJSCallbacks | () | method |
protected function assignJSCallbacks(paramObj:Object):void
AudioRecorder4JS suppport the following JS callbacks, as long as they are given
flashLoadEventHandler connectorEventHandler coreRequesterEventHandler micEventHandler recorderEventHandler factoryEventHandler errorEventHandler
Parameters
paramObj:Object |
coreRequesterEventHandler | () | method |
protected function coreRequesterEventHandler(event:CoreRequesterEvent):void
Parameters
event:CoreRequesterEvent |
See also
CoreRequestStatus | () | method |
public function CoreRequestStatus():String
get the core requester state
ReturnsString |
See also
disconnect | () | method |
factoryEventHandler | () | method |
protected function factoryEventHandler(event:FactoryEvent):void
Parameters
event:FactoryEvent |
See also
getConnectStatus | () | method |
public function getConnectStatus():String
get the connection state
ReturnsString |
See also
getMicStatus | () | method |
public function getMicStatus():String
get the mic status
ReturnsString |
See also
getMicVolume | () | method |
public function getMicVolume():Number
get mic volume (gain)
ReturnsNumber — 0-100
|
getNotifyAudioVolume | () | method |
public function getNotifyAudioVolume():Number
get Ding volume
ReturnsNumber — Ding volume 0-100
|
getRecorderStatus | () | method |
public function getRecorderStatus():String
get the recorder status
ReturnsString |
See also
getRecordTime | () | method |
public function getRecordTime():uint
TODO
Returnsuint |
getReplayAudioVolume | () | method |
public function getReplayAudioVolume():Number
get replay volume
ReturnsNumber |
getState | () | method |
public function getState():Object
Returns
Object — component states and configurations, as a JSON object
|
See also
hideAll | () | method |
public function hideAll():void
Hide microphone panel
hideVolumeViewer | () | method |
initRecorder | () | method |
protected function initRecorder(paramObj:Object):void
AudioRecorder4JS listens to the following ASSDK events
FactoryEvent.READY FactoryEvent.EXCEPTION_TIMEOUT NetEvent.EXCEPTION_CLOSED CoreRequesterEvent.RESULT CoreRequesterEvent.EXCEPTION_TIMEOUT CoreRequesterEvent.EXCEPTION_PARAMETERS_ERROR CoreRequesterEvent.EXCEPTION_RESPONSE_ERROR MicrophoneDeviceEvent.MIC_ALLOWED MicrophoneDeviceEvent.EXCEPTION_MIC_NOT_ALLOWED MicrophoneDeviceEvent.EXCEPTION_MIC_NOT_FOUND MicrophoneDeviceEvent.EXCEPTION_MMSCFG_SETTING MicrophoneVolumeSliderEvent.VOLUME_CHANGED RecorderEvent.RECORD_STOPPED RecorderEvent.RECORD_STARTED RecorderEvent.REPLAY_STOPPED RecorderEvent.REPLAY_STARTED RecorderEvent.EXCEPTION_NO_RECORD RecorderEvent.RECORDID_GOT
Parameters
paramObj:Object |
microphoneDeviceEventHandler | () | method |
protected function microphoneDeviceEventHandler(event:MicrophoneDeviceEvent):void
Parameters
event:MicrophoneDeviceEvent |
See also
microphonePanelEventHandler | () | method |
protected function microphonePanelEventHandler(event:MicrophoneVolumeSliderEvent):void
Parameters
event:MicrophoneVolumeSliderEvent |
See also
netEventHandler | () | method |
protected function netEventHandler(event:NetEvent):void
Parameters
event:NetEvent |
See also
reconnect | () | method |
recorderEventHandler | () | method |
protected function recorderEventHandler(event:RecorderEvent):void
Parameters
event:RecorderEvent |
See also
requestSpeechCore | () | method |
public function requestSpeechCore(params:Object):void
TODO: direct method call from javascript;
Parameters
params:Object |
returnCallBack | () | method |
protected function returnCallBack(callBack:String, statusCode:String, param:Object = null):void
Make JS callbacks
Note that, JSON String escapes the following characters: %, \, ", and amp (ASDoc does not parse amp character neither...)
text = text.split("%").join("%25") .split("\\").join("%5c") .split("\"").join("%22") .split("amp").join("%26");
JS side should do reverting before processing message
text = text.replace(/%22/g, "\"") .replace(/%5c/g, "\\") .replace(/%26/g, "amp") .replace(/%25/g, "%");
Parameters
callBack:String | |
statusCode:String | |
param:Object (default = null )
|
setMicrophoneLoopback | () | method |
public function setMicrophoneLoopback(isLoopback:Boolean):void
Parameters
isLoopback:Boolean |
showVolumeViewer | () | method |
public function showVolumeViewer(params:Object = null, barNum:int = 49):void
Parameters
params:Object (default = null )
| |
barNum:int (default = 49 )
|
See also
startRecord | () | method |
public function startRecord(param:Object):String
Start record
Parameters
param:Object |
String |
See also
startReplay | () | method |
public function startReplay(param:Object):String
Start replay
Parameters
param:Object |
String |
See also
stopRecord | () | method |
public function stopRecord(param:Object):String
Stop record
Parameters
param:Object |
String |
See also
stopReplay | () | method |
public function stopReplay(param:Object):String
Stop replay
Parameters
param:Object |
String |
See also
unHideAll | () | method |
public function unHideAll():void
Show microphone panel