'use strict';/*globals MediaRecorder*/
//Spec is athttp://dvcs.w3.org/hg/dap/raw-file/tip/media-stream-capture/RecordingProposal.html
navigator.getUserMedia= navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia ||navigator.msGetUserMedia;if(getBrowser() == "Chrome"){var constraints = {"audio": true, "video": { "mandatory": { "minWidth": 640, "maxWidth": 640, "minHeight": 480,"maxHeight": 480 }, "optional": [] } };//Chrome
}else if(getBrowser() == "Firefox"){var constraints = {audio: false, video: { width: { min: 640, ideal: 640, max: 640 }, height: { min: 480, ideal: 480, max: 480 }}}; //Firefox
}var recBtn = document.querySelector('button#rec');var pauseResBtn = document.querySelector('button#pauseRes');var stopBtn = document.querySelector('button#stop');var videoElement = document.querySelector('video');var dataElement = document.querySelector('#data');var downloadLink = document.querySelector('a#downloadLink');
videoElement.controls= false;
function errorCallback(error){
console.log('navigator.getUserMedia error:', error);
}/*var mediaSource = new MediaSource();
mediaSource.addEventListener('sourceopen', handleSourceOpen, false);
var sourceBuffer;*/
varmediaRecorder;var chunks =[];var count = 0;var wsurl = "ws://10.90.9.20:9080/RDConsumer/websocket"
var ws = null;
function createWs(){var url =wsurl;if ('WebSocket' inwindow) {
ws= newWebSocket(url);
}else if ('MozWebSocket' inwindow) {
ws= newMozWebSocket(url);
}else{
console.log("您的浏览器不支持WebSocket。");return;
}
}
function init() {if (ws != null) {
console.log("现已连接");return;
}
createWs();
ws.onopen=function() {//设置发信息送类型为:ArrayBuffer
ws.binaryType = "arraybuffer";