function getUserMedia(...args) { if (!hasGetUserMedia()) { return; return navigator.getUserMedia && navigator.getUserMedia(...args)|| navigator.webkitGetUserMedia && navigator.webkitGetUserMedia(...args)|| navigator.mozGetUserMedia && navigator.mozGetUserMedia(...args) || navigator.msGetUserMedia && navigator.msGetUserMedia(...args)
function hasGetUserMedia() { return !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
getMedia(callbacks) { navigator.getUserMedia = navigator.getUserMedia || navigator.mozGetUserMedia || navigator.mediaDevices.getUserMedia || navigator.webkitGetUserMedia; const constraints = { audio: true, video: true}; navigator.getUserMedia(constraints, callbacks.success, callbacks.error);
/** * Captures microphone input from the browser. * Works at least on latest versions of Firefox and Chrome function Microphone(_options) { var options = _options || {}; // we record in mono because the speech recognition service // does not support stereo. this.bufferSize = options.bufferSize || 8192; this.inputChannels = options.inputChannels || 1; this.outputChannels = options.outputChannels || 1; this.recording = false; this.requestedAccess = false; this.sampleRate = 16000; // auxiliar buffer to keep unused samples (used when doing downsampling) this.bufferUnusedSamples = new Float32Array(0); this.samplesAll = new Float32Array(20000000); this.samplesAllOffset = 0; // Chrome or Firefox or IE User media if (!navigator.getUserMedia) { navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
/** * Incorporate different versions of getUserMedia * @method initUserMedia() { if (navigator.mediaDevices === undefined) { navigator.mediaDevices = {}; if (navigator.mediaDevices.getUserMedia === undefined) { navigator.mediaDevices.getUserMedia = function (constraints) { let getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; if (!getUserMedia) { return Promise.reject(new Error('浏览器不支持 getUserMedia !')); return new Promise(function (resolve, reject) { getUserMedia.call(navigator, constraints, resolve, reject);
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
this.navigator = navigator;
requestMic() { return new Promise((resolve, reject) => { this._log('Requesting microphone.'); // Ensure that the file can be loaded in environments where navigator is not defined (node servers) if (!navigator.getUserMedia) { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; navigator.getUserMedia({ audio: true }, (stream) => { this._log('Microphone connected.'); return this.connectMediaStream(stream).then(resolve); }, (error) => { this._log('error', error); this.emit(AVS.EventTypes.ERROR, error); return reject(error);
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
constructor() { super(); navigator.getUserMedia = ( navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia); const audioCtx = new (window.AudioContext || webkitAudioContext)(); const analyser = audioCtx.createAnalyser(); this.state = { audioCtx: audioCtx, analyser: analyser, chunks: [] this.draw = this.draw.bind(this); this.visualize = this.visualize.bind(this); this.recordOnClick = this.recordOnClick.bind(this); this.stopOnClick = this.stopOnClick.bind(this); this.mediaRecorderOnStop = this.mediaRecorderOnStop.bind(this); this.mediaRecorderOnDataAvailable = this.mediaRecorderOnDataAvailable.bind(this);
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
startRecording() { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; if(typeof navigator.getUserMedia !== 'function') {
getMedia(callbacks) { navigator.getUserMedia = navigator.getUserMedia || navigator.mozGetUserMedia || navigator.mediaDevices.getUserMedia || navigator.webkitGetUserMedia; const constraints = { audio: true, video: true}; navigator.getUserMedia(constraints, callbacks.success, callbacks.error);
function hasGetUserMedia() { return !!(navigator.getUserMedia || navigator.webkitGetUserMedia ||