@bigbinary/neeto-media-recorder 2.7.28 → 2.7.29-beta.1

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
@@ -508,14 +508,44 @@ var UPLOAD_STATUS = {
508
508
  };
509
509
  var HAS_CHROME_NAMESPACE = (typeof chrome === "undefined" ? "undefined" : _typeof$1(chrome)) === "object";
510
510
  var IS_EXTENSION = HAS_CHROME_NAMESPACE && isNotNil(chrome.extension);
511
- platform.name === "Safari";
511
+ var IS_SAFARI = platform.name === "Safari";
512
+
513
+ // Firefox refuses to start a MediaRecorder on a stream that has both audio and
514
+ // video tracks unless the MIME string declares the audio codec too. Chromium
515
+ // and Safari accept the video-only form and silently pick Opus/AAC. We keep
516
+ // both variants and always prefer the codec-complete ones in
517
+ // getSupportedMimeType so a single code path works across browsers.
512
518
  var MIME_TYPE = {
513
519
  mp4: "video/mp4",
514
- webmH264: "video/webm;codecs=h264"
520
+ webmH264Opus: "video/webm;codecs=h264,opus",
521
+ webmH264: "video/webm;codecs=h264",
522
+ webmVp9Opus: "video/webm;codecs=vp9,opus",
523
+ webmVp9: "video/webm;codecs=vp9",
524
+ webmVp8Opus: "video/webm;codecs=vp8,opus",
525
+ webmVp8: "video/webm;codecs=vp8",
526
+ webm: "video/webm"
515
527
  };
516
528
 
529
+ // Picks the best MediaRecorder MIME type the current browser supports.
530
+ // Chromium produces H.264-in-WebM, Safari only produces MP4, and Firefox
531
+ // produces VP9/VP8-in-WebM. Returns null if none of the candidates are
532
+ // supported so callers can surface an "unsupported browser" state.
517
533
  var getSupportedMimeType = function getSupportedMimeType() {
518
- return MIME_TYPE.webmH264;
534
+ var _candidates$find;
535
+ if (typeof MediaRecorder === "undefined") return null;
536
+
537
+ // Safari only exposes a working MediaRecorder for MP4.
538
+ if (IS_SAFARI && MediaRecorder.isTypeSupported(MIME_TYPE.mp4)) {
539
+ return MIME_TYPE.mp4;
540
+ }
541
+
542
+ // Prefer types that declare the audio codec explicitly. Firefox requires
543
+ // this when the MediaStream has both audio and video tracks; Chromium and
544
+ // Safari are happy with either form.
545
+ var candidates = [MIME_TYPE.webmH264Opus, MIME_TYPE.webmVp9Opus, MIME_TYPE.webmVp8Opus, MIME_TYPE.webmH264, MIME_TYPE.webmVp9, MIME_TYPE.webmVp8, MIME_TYPE.webm, MIME_TYPE.mp4];
546
+ return (_candidates$find = candidates.find(function (type) {
547
+ return MediaRecorder.isTypeSupported(type);
548
+ })) !== null && _candidates$find !== void 0 ? _candidates$find : null;
519
549
  };
520
550
 
521
551
  var formatTime = function formatTime(time) {
@@ -1651,7 +1681,7 @@ var useRecorderStore = screenRecorder.useRecorderStore,
1651
1681
  restartRecording = screenRecorder.restartRecording,
1652
1682
  discardRecording = screenRecorder.discardRecording;
1653
1683
  var globalProps = ((_window = window) === null || _window === void 0 ? void 0 : _window.globalProps) || {};
1654
- var MediaRecorder = function MediaRecorder(_ref, ref) {
1684
+ var MediaRecorder$1 = function MediaRecorder(_ref, ref) {
1655
1685
  var _ref$onUploadComplete = _ref.onUploadComplete,
1656
1686
  onUploadComplete = _ref$onUploadComplete === void 0 ? noop : _ref$onUploadComplete,
1657
1687
  _ref$onDiscard = _ref.onDiscard,
@@ -2076,7 +2106,7 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
2076
2106
  })]
2077
2107
  });
2078
2108
  };
2079
- var index = /*#__PURE__*/forwardRef(MediaRecorder);
2109
+ var index = /*#__PURE__*/forwardRef(MediaRecorder$1);
2080
2110
 
2081
2111
  export { index as MediaRecorder };
2082
2112
  //# sourceMappingURL=index.js.map