
function setProgress(percent){
    $('input[type="range"]').val(percent).change();
}

function doAction(func){
    callFunc(func, '');
}

function queryVideoList(){

    var videos = $.checkTask.video_id.split(',');

    if(curVideo) {
        s1 = $.checkTask.start_time.replace(/-/g,"/");
        var startTime = new Date(s1).getTime()/1000;
        s1 = $.checkTask.end_time.replace(/-/g,"/");
        var endTime = new Date(s1).getTime()/1000;
        //获取当前的index
        var index = 0;

        for(var i = 0;i<videos.length;i++){
              
             if(parseInt(videos[i])==parseInt(curVideo)){
                index = i;
                break;
             }
        }
      
        //获取摄像头信息
        VideoGetById(curVideo,function(data){
            if(data!=null && typeof(data)!="undefined"){
                var str = curVideo+'|'+startTime+'|'+endTime+'|'+data.cameratype+'|'+data.playtype+'|'+index;
                callFunc("findvideolist",str);
            }
        },function(error){

        });

        // alert(curVideo);
        
    }else{

    }
}

function playVideo(id){
    callFunc("playvideo", id);
}
var maxVV;
function setProcessValue(maxValue){
     //alert(maxValue);
    // console.log(max);
    maxVV = maxValue;
    $("#ex1").slider({step: 5, min: 0, max: maxValue});
    if($("#full_ex1")){
         $("#full_ex1").slider({step: 5, min: 0, max: maxValue});
    }
}

function setCurrentProcessValue(value){
    // alert("ddd"+value);
    // console.log(value);
    
    var vv =maxVV*(value/100)

    $("#ex1").slider('setValue',parseInt(vv));
     if($("#full_ex1")){
         $("#full_ex1").slider('setValue',parseInt(vv));
    }
}

function setVideoProcess(value){
    // console.log(value);
    var vv = value*100/maxVV;
    if(!isNaN(vv) && parseInt(vv).toString() != "NaN") {
          callFunc("setcurrenplayttime", parseInt(vv)); 
    }else{

    }
    
}

function callFunc(func, param){
    var event = document.createEvent('MessageEvent');
    var origin = window.location.protocol + '//' + window.location.host;
    event.initMessageEvent (func, true, true, param, origin, 1234, window, null);
    document.dispatchEvent (event);
}

function playNext(index){
    $("#video_list").val(index);
}