Open imoxto opened 1 year ago
Hi, have you figured out any workaround for this?
Hi, have you figured out any workaround for this?
For now im just keeping the screen awake while recording
+1
Submitted this a few days ago as well.
Does this NPM supports android API level 33
Al parecer no es un tema de la librería como tal, creería que es debido a como el SO lo cataloga. Al usarlo en React Native y tenerlo en segundo plano puede ser que sea menos prioritario que una llamada telefónica que también usa el micrófono pero en una app nativa. De todas formas también tengo el mismo problema (+1). Veo como solución usar un modulo nativo de Kotlin y hacer un bridge a mi app de React Native.
have you enabled "Audio, AirPlay, and Picture in Picture" option in xcode> Signing&Capabilities > Background Modes?
+1 Experiencing basically the same issue here. Audio keeps recording when the device is locked, but a short time after locking (usually 30secs to 2mins) the audio levels become zero - it just records silence. The audio file then continues to be created, recording silence while the device is locked. When the device is later unlocked, the audio file continues to be created, and instead of recording silence the audio signal is restored to normal expected behaviour.
Any suggestions for improving this behaviour (other than keeping the screen unlocked)?
react-native version: 0.72.4 react-native-audio-recorder-player version: 3.6.0 release build tested on Oppo A52 (CPH2069) w/ Android 11, ColorOS v11.1
Anyone solved this issue? i am also facing same issue
I did the solution like this and it works fine in my case. anyone can apply this way
react-native version: 0.72.6 react-native-audio-recorder-player version: 3.6.12
import React, {useState, useEffect, useRef} from 'react';
import { AppState} from 'react-native';
import AudioRecorderPlayer from 'react-native-audio-recorder-player';
import {useIsFocused} from '@react-navigation/native';
const isFocused = useIsFocused();
const [isPlaying, setIsPlaying] = useState(false);
const appState = useRef(AppState.currentState);
// Handle stopping audio when navigating away or unmounting the component
useEffect(() => {
if (!isFocused) {
// Component is not focused, stop audio playback
stopAudioPlayback();
}
// Cleanup function to stop audio playback when component unmounts
return () => {
stopAudioPlayback();
};
}, [isFocused]);
// Function to stop audio playback
const stopAudioPlayback = () => {
try {
audioRecorderPlayerRef.current.stopPlayer();
audioRecorderPlayerRef.current.removePlayBackListener();
setIsPlaying(false);
} catch (error) {
console.warn('Error stopping audio playback:', error);
}
};
// background playback issue solution
useEffect(() => {
const handleAppStateChange = (nextAppState) => {
if (appState.current.match(/inactive|background/) && nextAppState === 'active') {
// App comes to the foreground, do nothing
} else if (nextAppState.match(/inactive|background/)) {
// App goes to the background, stop audio playback
audioRecorderPlayerRef.current.stopPlayer();
audioRecorderPlayerRef.current.removePlayBackListener();
setIsPlaying(false);
}
appState.current = nextAppState;
};
const appStateListener = AppState.addEventListener('change', handleAppStateChange);
return () => {
// Cleanup the AppState listener on component unmount
appStateListener.remove();
};
}, []);
Hello, I basically want to run the recording for a while even after the phone is locked. But i couldnt find any ideas on how to go about it in the docs. Any help is appreciated.
Version of react-native-audio-recorder-player
3.6.0
Version of React Native
0.72.4
Platforms you faced the error (IOS or Android or both?)
Android
Expected behavior
Press a button to start recording audio. Then lock the phone. I want to be able to record audio always after the app is locked.
Actual behavior
After locking the phone, it records for about 1 to 3 minutess after locking screen. but afterwards it doesn't record anymore untill the lock is lifted.
Steps to reproduce the behavior
Press a button to start recording audio. Then lock the phone and keep talking for 3 mins. Turn on the phone and stop recording and observe the playback file.
The following is the rough code i used: