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');
			}
		});

screen shot 2017-02-27 at 1 11 36 pm screen shot 2017-02-27 at 1 11 07 pm

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22

Most upvoted comments

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');

const s = new Sound(requireAudio, (e) => {
      if (e) {
        console.log('error', e);
        return;
      }
      s.play(() => s.release());
      });

@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:

const s = new Sound('advertising.mp3', Sound.MAIN_BUNDLE, (e) => {
        if (e) {
          console.log('error', e);
        } else {
          s.setSpeed(1);
          console.log('duration', s.getDuration());
          s.play(() => s.release()); // Release when it's done so we're not using up resources
        }
      });

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.