react-native-sound: The operation couldn’t be completed. (OSStatus error -10875.)
Hello, guys. I have the following error when trying to play a sound. I will attach an image of the error below. Here is my code:
import Sounddd from 'react-native-sound';
const sTest = new Sounddd('test.mp3', Sounddd.MAIN_BUNDLE, (error) => {
if (error) {
console.log('failed to load the sound', error);
return;
}
// loaded successfully
console.log('duration in seconds: ' + sTest.getDuration() + 'number of channels: ' + sTest.getNumberOfChannels());
});
sTest.play((success) => {
if (success) {
console.log('successfully finished playing');
} else {
console.log('playback failed due to audio decoding errors');
}
});
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22
Hi for what it’s worth, I’ve been getting this error and after rolling my project back to earlier commits I discovered that sound stopped working after I changed the project’s “Display Name” to something with a space in it. Going back to a name without spaces made it work again.
@zakster12 had the same problem related to the audio path , made it work by using
const requireAudio = require('./test.mp3');
@freiserg @zakster12 So react-native-sound-demo works fine with RNSound 0.9.0.
Checking into it the difference is that in there I wait for the constructor callback before calling .play()
e.g:
If I move the
s.play()
line to where you have it (i.e. immediately after the new Sound command) then the audio fails to play.So a workaround is to use the callback before you play the audio.
EDIT: Looking at the sound.js file the play command is ignored if the file isn’t loaded. Always use the callback before calling play 😃
@Ali-Ayyad with your snippet of code right now I do not have any errors but there is no sound at all. I tried with .mp3 and with .wav and there is no sound.