@bigbinary/neeto-media-recorder 2.7.27 → 2.7.28

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
@@ -1251,7 +1251,9 @@ var FailedToStart = withT(function (_ref) {
1251
1251
  var getAnalyser = function getAnalyser() {
1252
1252
  var _screenRecorder$getAu;
1253
1253
  var stream = (_screenRecorder$getAu = screenRecorder.getAudioStream) === null || _screenRecorder$getAu === void 0 ? void 0 : _screenRecorder$getAu.call(screenRecorder);
1254
- if (!stream) return null;
1254
+ if (!stream) {
1255
+ return null;
1256
+ }
1255
1257
  var ctx = new (window.AudioContext || window.webkitAudioContext)();
1256
1258
  var source = ctx.createMediaStreamSource(stream);
1257
1259
  var analyser = ctx.createAnalyser();
@@ -1337,8 +1339,7 @@ var useAudioIsCapturing = function useAudioIsCapturing(_ref) {
1337
1339
  useEffect(function () {
1338
1340
  if (!isMicOn || !timerStarted || disable) return noop;
1339
1341
  var analyserObj = null;
1340
- var rafId;
1341
- var loop = function loop() {
1342
+ var checkAudio = function checkAudio() {
1342
1343
  if (!analyserObj) analyserObj = getAnalyser();
1343
1344
  // if no stream yet or analyser failed, treat as silence
1344
1345
  var isSilent = !analyserObj ? true : function () {
@@ -1355,11 +1356,13 @@ var useAudioIsCapturing = function useAudioIsCapturing(_ref) {
1355
1356
  remainingRef.current = MIC_NOT_WORKING_SILENCE_TIMEOUT;
1356
1357
  if (!hasAudio) setHasAudio(true);
1357
1358
  }
1358
- rafId = requestAnimationFrame(loop);
1359
1359
  };
1360
- loop();
1360
+
1361
+ // Use interval polling instead of rAF so this keeps running in inactive tabs.
1362
+ checkAudio();
1363
+ var intervalId = setInterval(checkAudio, 1000);
1361
1364
  return function () {
1362
- cancelAnimationFrame(rafId);
1365
+ clearInterval(intervalId);
1363
1366
  clearTimer();
1364
1367
  if (analyserObj) {
1365
1368
  analyserObj.source.disconnect();