UNPKG

enumerate-devices-shim

Version:

Enable a consistent use of navigator.mediaDevices.enumerateDevices on browsers that support it.

51 lines (45 loc) 1.77 kB
/* * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. */ /* eslint-env node */ 'use strict'; // Shimming starts here. (function() { // Utils. var logging = require('./utils').log; var browserDetails = require('./utils').browserDetails; // Export to the adapter global object visible in the browser. module.exports.browserDetails = browserDetails; module.exports.extractVersion = require('./utils').extractVersion; module.exports.disableLog = require('./utils').disableLog; // Comment out the line below if you want logging to occur, including logging // for the switch statement below. Can also be turned on in the browser via // adapter.disableLog(false), but then logging from the switch statement below // will not appear. require('./utils').disableLog(true); // Browser shims. var chromeShim = require('./chrome/chrome_shim') || null; var firefoxShim = require('./firefox/firefox_shim') || null; // Shim browser if found. switch (browserDetails.browser) { case 'opera': // fallthrough as it uses chrome shims case 'chrome': logging('enumerateDevices shimming chrome.'); // Export to the adapter global object visible in the browser. module.exports.browserShim = chromeShim; chromeShim.shimEnumerateDevices(); break; case 'firefox': logging('enumerateDevices shimming firefox.'); // Export to the adapter global object visible in the browser. module.exports.browserShim = firefoxShim; firefoxShim.shimEnumerateDevices(); break; default: logging('Unsupported browser!'); } })();