react-native-audio-recorder-player
react-native-audio-recorder-player copied to clipboard
Unable to play the audio on iOS because the file path is getting corrupted
Please fill the template to help you out. Also, please try the
Example
project compare before submiting the issue when you have certain issue with your project setup.
Version of react-native-audio-recorder-player - "react-native-audio-recorder-player": "^3.5.3"
Version of React Native - "react-native": "0.68.5"
Platforms you faced the error (IOS or Android or both?) - iOS
Expected behavior - Audio should play if the file is available in the storage
Actual behavior - Audio is not getting played on iOS
Steps to reproduce the behabior:
@hyochan, first of all, a big thanks to this awesome package!
I found an issue that makes it impossible for me to play audio on iOS:
const path = `${RNFS.CachesDirectoryPath}/${Date.now()}audioOut.mp3`;
const audioPlayedFromPath = await audioRecorderPlayer.startPlayer(path);
For me, on both the iOS simulator and in device, if given like the above, the audioPlayedFromPath
is getting corrupted/repeated as below:
file:///var/mobile/Containers/Data/Application/5E03275B-C193-4ABE-809A-8D8C7C1B8252/Library/Caches//var/mobile/Containers/Data/Application/5E03275B-C193-4ABE-809A-8D8C7C1B8252/Library/Caches/1681391103391audioOut.mp3
Because of this, I had to manually add file://
and then the issue is resolved.
const path = `${RNFS.CachesDirectoryPath}/${Date.now()}audioOut.mp3`;
await audioRecorderPlayer.startPlayer(`file://${path}`);
I'm open to give any further info or to create a PR if needed.
maybe u are facing this problem because u are using .mp3 format
when recording library throws error when u are trying ot record smth using mp3 format, maybe the same issue is appearing when u are playing sound, try using m4a format, works both IOS and Android