Skip to content

Instantly share code, notes, and snippets.

@wallacemaxters
Created November 25, 2015 12:44
Show Gist options
  • Save wallacemaxters/06fee08f1c7b50e8896d to your computer and use it in GitHub Desktop.
Save wallacemaxters/06fee08f1c7b50e8896d to your computer and use it in GitHub Desktop.
Cross browser of GetUserMedia
function getUserMedia () {
return (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia).apply(navigator, arguments)
}
@wallacemaxters
Copy link
Author

Usage of GetUserMedia:

var onSuccess = function (media)
{
      var src = window.URL.createObjectURL(media);

     video.src = src;

     // OR in jQuery

    $('#video').attr('src', src);
}

var onError = function () { alert('Error! ;'); }

getUserMedia({video: true}, onSuccess,  onError);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment