code: function getMediaDevices () {
    if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
      return navigator.mediaDevices
    }
  
    const getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia
    if (!getUserMedia) {
      return null
    }
  
    return {
      getUserMedia (opts) {
        return new Promise((resolve, reject) => {
          getUserMedia.call(navigator, opts, resolve, reject)
        })
      }
    }
  }
docs: Setup getUserMedia, with polyfill for older browsers Adapted from: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia