Skip to content

Instantly share code, notes, and snippets.

@aike
Created September 1, 2014 03:22
Show Gist options
  • Save aike/e0c4b9062b42b87de8b1 to your computer and use it in GitHub Desktop.
Save aike/e0c4b9062b42b87de8b1 to your computer and use it in GitHub Desktop.
getUserMedia API mock for audio
// This program is licensed under the MIT License.
navigator.webkitGetUserMedia = function(opt, ok, ng) {
ok(null);
};
AudioContext.prototype.createMediaStreamSource = function() {
var osc = this.createOscillator();
osc.type = 'sine';
var gain = this.createGain();
gain.gain.value = 0.0;
osc.connect(gain);
osc.start(0);
setInterval(function() {
gain.gain.value = 0.5;
setTimeout(function() { gain.gain.value = 0.0; }, 800);
}, 1000);
return gain;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment