Here's an example of using getUserMedia(), including code to cope with various browsers' prefixes.
Select the View>Source menu to see the javascript source
Adapted from MDN - navigator.getMedia() Method