@whereby.com/media 9.2.2 → 9.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2473,9 +2473,11 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2473
2473
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2474
2474
  const audioDevices = devices.filter((d) => d.kind === "audioinput");
2475
2475
  const videoDevices = devices.filter((d) => d.kind === "videoinput");
2476
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2477
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2476
2478
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2477
- audioId: typeof audioId === "string" ? { [type]: audioId } : null,
2478
- videoId: typeof videoId === "string" ? { [type]: videoId } : null,
2479
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2480
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2479
2481
  } }, options));
2480
2482
  if (audioId === false || !audioDevices.length) {
2481
2483
  delete constraints.audio;
package/dist/index.mjs CHANGED
@@ -2452,9 +2452,11 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2452
2452
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2453
2453
  const audioDevices = devices.filter((d) => d.kind === "audioinput");
2454
2454
  const videoDevices = devices.filter((d) => d.kind === "videoinput");
2455
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2456
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2455
2457
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2456
- audioId: typeof audioId === "string" ? { [type]: audioId } : null,
2457
- videoId: typeof videoId === "string" ? { [type]: videoId } : null,
2458
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2459
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2458
2460
  } }, options));
2459
2461
  if (audioId === false || !audioDevices.length) {
2460
2462
  delete constraints.audio;
@@ -2452,9 +2452,11 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2452
2452
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2453
2453
  const audioDevices = devices.filter((d) => d.kind === "audioinput");
2454
2454
  const videoDevices = devices.filter((d) => d.kind === "videoinput");
2455
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2456
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2455
2457
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2456
- audioId: typeof audioId === "string" ? { [type]: audioId } : null,
2457
- videoId: typeof videoId === "string" ? { [type]: videoId } : null,
2458
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2459
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2458
2460
  } }, options));
2459
2461
  if (audioId === false || !audioDevices.length) {
2460
2462
  delete constraints.audio;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "9.2.2",
4
+ "version": "9.2.3",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {