I am trying this in Chrome on a Mac:
function SoundRecorder() {
}
SoundRecorder.prototype.recordSound = function() {
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
if (!navigator.getUserMedia) {
alert('Media is not supported in your browser');
return;
}
navigator.getUserMedia({
audio: true
}, this.success, this.failure);
};
SoundRecorder.prototype.success = function(e) {
console.log(this == window);
};
SoundRecorder.prototype.failure = function() {
return alert('You denied permission');
};
When I run
new SoundRecorder().recordSound()
it prints out true. Shouldn't the value of this be an 'instance' of SoundRecoder. I am missing something or is this a Chrome Bug?
I tried it in Firefox and the value of this was "SoundRecorder.prototype.success"