@bigbinary/neeto-media-recorder 2.4.0 → 2.4.2

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/index.js CHANGED
@@ -13,7 +13,7 @@ import { useTranslation, Trans } from 'react-i18next';
13
13
  import { useMutation } from '@tanstack/react-query';
14
14
  import axios from 'axios';
15
15
  import platform from 'platform';
16
- import { isNotNil, isEmpty } from 'ramda';
16
+ import { isNotNil, isNil, isEmpty } from 'ramda';
17
17
  import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
18
18
  import Spinner from '@bigbinary/neetoui/Spinner';
19
19
  import { jsx, jsxs } from 'react/jsx-runtime';
@@ -524,9 +524,34 @@ var MIME_TYPE = {
524
524
  };
525
525
  // 2 hours
526
526
 
527
+ // https://www.w3.org/TR/screen-capture/#displaycapturesurfacetype
528
+ var MINIMUM_CHROMIUM_VERSION_FOR_MP4 = "128.0.6613.85";
529
+
530
+ function getChromiumVersion() {
531
+ var userAgent = navigator.userAgent;
532
+ var match = userAgent.match(/Chrom(e|ium)\/(([0-9][.]?)+)/);
533
+ if (match) {
534
+ return match[2];
535
+ }
536
+ return null;
537
+ }
538
+ var versionToInteger = function versionToInteger(version) {
539
+ return parseInt(version.replaceAll(".", ""));
540
+ };
527
541
  var getSupportedMimeType = function getSupportedMimeType(fallback) {
528
542
  if (MediaRecorder.isTypeSupported(MIME_TYPE.mp4)) {
529
- return MIME_TYPE.mp4;
543
+ if (platform.name === "Safari") {
544
+ return MIME_TYPE.mp4;
545
+ }
546
+ var chromiumVersion = getChromiumVersion();
547
+ if (isNil(chromiumVersion)) {
548
+ return MIME_TYPE.webmH264;
549
+ }
550
+ var isChromiumVersionSupported = versionToInteger(chromiumVersion) >= versionToInteger(MINIMUM_CHROMIUM_VERSION_FOR_MP4);
551
+ if (isChromiumVersionSupported) {
552
+ return MIME_TYPE.mp4;
553
+ }
554
+ return MIME_TYPE.webmH264;
530
555
  } else if (MediaRecorder.isTypeSupported(MIME_TYPE.webmH264)) {
531
556
  return MIME_TYPE.webmH264;
532
557
  }