(function(__mp){
   return {
     //%%
     get_event_data:function(args){
       var data_array=[];
       if(!args||!args instanceof Array)return[];
       for(var i=2;i<args.length;i++)
	 data_array[i-2]=args[i];
       return data_array;
     },
     set_params:function(param){
       this.set_params_result=false;
       var tbl=["heartbeatPeriod","sd2HDThreshold","hd2SDThreshold","deviceID",
		"drmServerURL","drmAckServerURL","heartbeatURL","titleLocation","hdTitleLocation","portal","storefront"];
       var str_param="";
       for(var i in param){
	 for(var j=0;j<tbl.length;j++)if(i==tbl[j])break;
	 if (j==tbl.length){throw new Error("set_params() invalid item "+i);return false;}
	 if (i=="heartbeatPeriod"||i=="sd2HDThreshold"||i=="hd2SDThreshold"){
	   str_param+=i+":"+param[i]+",";
	 } else {
	     if (param[i] != null)
	     {
		 param[i] = param[i].replace(/%/g,"%25");
		 param[i] = param[i].replace(/\"/g,"%22");
		 str_param+=i+":\""+param[i]+"\",";
	     }
	 }
       }
       __mp._request(true,this.sync_callback,this.SET_PARAMS,str_param);
       return this.set_params_result;
     },
     play:function(rate){
       if(typeof rate == 'undefined')rate=1;
       __mp._request(false,null,this.CONTROL_PLAY,rate);
     },
     stop:function(){__mp._request(false,null,this.CONTROL_STOP);},
     pause:function(obj){__mp._request(false,null,this.CONTROL_PAUSE);},
     seek:function(seek){__mp._request(false,null,this.CONTROL_SEEK,seek);},
     skip:function(skip){__mp._request(false,null,this.CONTROL_SKIP,skip);},
     del_movie:function(){__mp._request(false,null,this.CONTROL_RELEASE);},
     sync_callback:function(obj,event,data){
       switch(event){
       case obj.EV_SET_PARAMS:
	 obj.set_params_result=data;
	 break;
       case obj.EV_GET_DURATION:
	 obj.duration=data;
	 break;
       case obj.EV_GET_ELAPSED:
	 obj.elapsed=data;
	 break;
       case obj.EV_GET_VIDEO_RESOLUTION:
	 obj.vres=obj.get_event_data(arguments);
	 break;
       case obj.EV_GET_ORG_RESOLUTION:
	 obj.orgres=obj.get_event_data(arguments);
	 break;
       case obj.EV_GET_STATE:
	 obj.state=data;
	 break;
       case obj.EV_GET_BANDWIDTH:
	 obj.bw=data;
	 break;
       case obj.EV_GET_STREAM_RATE:
	 obj.rate=data;
	 break;
       case obj.EV_GET_RATE_METRICS:
	 obj.rate_metrics=obj.get_event_data(arguments);
	 break;
       case obj.EV_GET_RATE_INDEX:
	 obj.rate_index=data;
	 break;
       case obj.EV_GET_ERROR:
	 obj.error=data;
	 break;
       case obj.EV_GET_HTTP_STATUS:
	 obj.http_status=data;
	 break;
       case obj.EV_GET_CLIENT_STATUS:
	 obj.client_status=data;
	 break;
       case obj.EV_GET_WV_STATUS:
	 obj.wv_status=data;
	 break;
       }
     },
     get_duration:function(){
       this.duration=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request((!__mp.__async),cb_func,this.GET_DURATION);
       return this.duration;
     },
     get_elapsed:function(){
       this.elapsed=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_ELAPSED);
       return this.elapsed;
     },
     get_state:function(){
       this.state=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_STATE);
       return this.state;
     },
     get_video_resolution:function(){
       this.vres=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_VIDEO_RESOLUTION);
       return this.vres;
     },
     get_org_resolution:function(){
       this.orgres=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_ORG_RESOLUTION);
       return this.orgres;
     },
     get_error:function(){
       this.error=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_ERROR);
       return this.error;
     },
     get_http_status:function(){
       this.http_status=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_HTTP_STATUS);
       return this.http_status;
     },
     get_client_status:function(){
       this.client_status=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_CLIENT_STATUS);
       return this.client_status;
     },
     get_widevine_status:function(){
       this.wv_status=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_WV_STATUS);
       return this.wv_status;
     },
     get_net_band_width:function(){
       this.bw=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_BANDWIDTH);
       return this.bw;
     },
     get_stream_bitrate:function(){
       this.rate=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_STREAM_RATE);
       return this.rate;
     },
     get_stream_bitrates_metrics:function(){
       this.rate_metrics=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_RATE_METRICS);
       return this.rate_metrics;
     },
     get_current_bitrate_index:function(){
       this.rate_index=undefined;
       var cb_func=null;
       if(!__mp.__async)cb_func=this.sync_callback;
       __mp._request(!__mp.__async,cb_func,this.GET_RATE_INDEX);
       return this.rate_index;
     }
   };
 })(this);
