When I try to do the following:
var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
// now I try to invoke it with some parameters:
getUserMedia(...) // not working!
It throws an error "Illegal Invocation" in Chrome.
But if I do:
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
// now invoke it with the navigator
navigator.getUserMedia(..) // Works
I've tried searching a bit, and I read it's a context issue. But I still couldn't understand what's the meaning of that. In the first example, the getUserMedia variable ends up getting a reference to the function which is not undefiend (i.e, in case of chrome, it's webkitGetUserMedia), so why cannot I invoke it using this variable?
(This is actually a general JavaScript question, not specific to WebRTC.)