
﻿
(function(win){var MESSAGE_ORIGIN='AndroidRecorderAdapter';function AndroidRecorderAdapter(option){window.addEventListener('message',function(e){if(typeof e.data==="string"){e=eval('('+e.data+')');}
if(!e||!e.data.evt||e.data.origin!==MESSAGE_ORIGIN)
return;var playerEventType=e.data.evt;var data;if(e.data.data){data=e.data.data;}
switch(playerEventType){case'onReady':_recorder.jsInterface.onReady();break;case'onError':_recorder.jsInterface.onError(data);break;case'onEvalResult':_recorder.jsInterface.onEvalResult(data);break;case'onTrackInfo':_recorder.jsInterface.onTrackInfo(data);break;case'onRecordBegin':_recorder.jsInterface.onRecordBegin();break;case'onRecordEnd':_recorder.jsInterface.onRecordEnd();break;case'onRecording':_recorder.jsInterface.onRecording(data);break;case'onAudioLoaded':_recorder.jsInterface.onAudioLoaded(data);break;case'onPlayBegin':_recorder.jsInterface.onPlayBegin(data);break;case'onPlayStop':_recorder.jsInterface.onPlayStop(data);break;case'onPlaying':_recorder.jsInterface.onPlaying(data);break;}},false);var _this=this;_this.id=option.id||"speech-recorder-adapter-"+new Date().getTime();var _recorder=new AndroidRecorderObj(option);this.__proxy__.record=function(recordOprion){return _recorder.record(recordOprion);};this.__proxy__.stop=function(isForce){return _recorder.stop(isForce);};this.loadAudio=function(audioId,autoPlay){_recorder.loadAudio(audioId,autoPlay);};this.play=function(){_recorder.play();};this.playRange=function(begPos,endPos){_recorder.playRange(begPos,endPos);};this.pause=function(){_recorder.pause();};this.stopPlay=function(){_recorder.stopPlay();};this.getFlashPlayerState=function(){return _recorder.getFlashPlayerState();};this.__class__.check.call(this);setTimeout(function(){_recorder.jsInterface.onReady();},0);}
function AndroidRecorderObj(option){var _this=this;_this.events=option.events||{};_this.androidInterface=win.AndroidRecorderInterface;_this.jsInterface={onReady:function(){var callback=_this.events.onReady;if(callback){callback();}},onRecordBegin:function(e){var callback=_this.events.onRecordBegin;if(callback){callback(e);}},onRecordEnd:function(e){var callback=_this.events.onRecordEnd;if(callback){callback(e);}},onRecording:function(e){var callback=_this.events.onRecording;if(callback){callback(e);}},onTrackInfo:function(e){var callback=_this.events.onTrackInfo;if(callback){callback(e);}},onEvalResult:function(e){var callback=_this.events.onEvalResult;if(callback){callback(e);}},onError:function(e){var callback=_this.events.onError;if(callback){callback(e);}},onAudioLoaded:function(e){var callback=_this.events.onAudioLoaded;if(callback){callback(e);}},onPlayBegin:function(e){var callback=_this.events.onPlayBegin;if(callback){callback(e);}},onPlayStop:function(e){var callback=_this.events.onPlayStop;if(callback){callback(e);}},onPlaying:function(e){var callback=_this.events.onPlaying;if(callback){callback(e);}}};}
AndroidRecorderObj.prototype={record:function(recordOption){var msg={evt:'record',origin:MESSAGE_ORIGIN,data:recordOption};window.parent.postMessage(msg,'*');return true;},stop:function(isForce){var msg={evt:'stop',origin:MESSAGE_ORIGIN,data:{isForce:isForce}};window.parent.postMessage(msg,'*');return true;},loadAudio:function(audioId,autoPlay){var msg={evt:'loadAudio',origin:MESSAGE_ORIGIN,data:{audioId:audioId,autoPlay:autoPlay!==false}};window.parent.postMessage(msg,'*');},play:function(){var msg={evt:'play',origin:MESSAGE_ORIGIN};window.parent.postMessage(msg,'*');},playRange:function(begPos,endPos){var msg={evt:'playRange',origin:MESSAGE_ORIGIN,data:{begPos:begPos,endPos:endPos}};window.parent.postMessage(msg,'*');},pause:function(){},stopPlay:function(){var msg={evt:'stopPlay',origin:MESSAGE_ORIGIN};window.parent.postMessage(msg,'*');}};AndroidRecorderAdapter.prototype=new SpeechJS.RecorderAdapterBase();AndroidRecorderAdapter.prototype.constructor=AndroidRecorderAdapter;win.AndroidRecorderAdapter=AndroidRecorderAdapter;})(window);