Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The operation couldn’t be completed. (OSStatus error -10875.) #120

Closed
zakster12 opened this issue Feb 27, 2017 · 22 comments
Closed

The operation couldn’t be completed. (OSStatus error -10875.) #120

zakster12 opened this issue Feb 27, 2017 · 22 comments

Comments

@zakster12
Copy link

zakster12 commented Feb 27, 2017

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

@benvium
Copy link
Collaborator

benvium commented Feb 27, 2017

Perhaps it's the typo in your code Sounddd.MAIN_BUNDLE => Sound.MAIN_BUNDLE?

@zakster12
Copy link
Author

zakster12 commented Feb 27, 2017

I think it's not a typo because I imported it as Sounddd. But to be sure I tested like this:

import Sound from 'react-native-sound';

export default class iChat extends Component {

	onPressPlay() {
		console.log('Play');

		const whoosh = new Sound('test.mp3', Sound.MAIN_BUNDLE, (error) => {
			if (error) {
				console.log('failed to load the sound', error);
				return;
			}
		});

		whoosh.play((success) => {
			if (success) {
				console.log('successfully finished playing');
			} else {
				console.log('playback failed due to audio decoding errors');
			}
		});
	}

And I have the same error

@benvium
Copy link
Collaborator

benvium commented Feb 27, 2017

@zakster12 Ah you are right about the import, apologies.

Can you check the mp3 is included in the app bundle (build phases, copy bundle resources)?

@zakster12
Copy link
Author

@benvium thanks for trying to help me. Yes, the mp3 is listed there.

screen shot 2017-02-27 at 4 47 55 pm

@Ali-Ayyad
Copy link

@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
Copy link

@benvium I have the same problem after updating to 0.9.0. It's working in 0.8.3. I rolled back this commit 882c663 and It works.

@zakster12
Copy link
Author

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

@benvium
Copy link
Collaborator

benvium commented Mar 1, 2017

@freiserg Thanks for that - sounds like there's been a regression due to that commit. I'll investigate

@benvium
Copy link
Collaborator

benvium commented Mar 1, 2017

@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
Copy link

@zakster12 try Sound.setCategory('Playback', true)

@benvium
Copy link
Collaborator

benvium commented Mar 3, 2017

There was a bug preventing setCategory from working if the mixWithOthers param wasn't set see #124. I made a PR to fix that..
EDIT: which is now merged and published to npm as 0.9.1

@lagofvc
Copy link

lagofvc commented Mar 28, 2017

Thanx for the suggestions here: @Ali-Ayyad @benvium , I got rid of this errors, but I am also experiencing the exact set of descriptions that @zakster12 gave. Currently no sound. 0.9.1

@Darthmaul
Copy link

Hello

I'm having a similar issue as @lagofvc . No errors in my code besides failing to play the sound. Getting "The operation couldn't be completed", even though I have included my sound on Xcode and have basically just copy and pasted from the demo code.

Any troubleshooting that should be done to go about fixing this?

@benvium
Copy link
Collaborator

benvium commented Mar 28, 2017

@lagofvc @Darthmaul I presume you've tried Sound.setCategory('Playback', true) before playing any audio?

@Darthmaul
Copy link

Darthmaul commented Mar 28, 2017

Resolved

@lagofvc
Copy link

lagofvc commented Mar 28, 2017

@benvium , Thanx! Yes, I did try with the .setCategory('Playback', true);.
As a side note I have the exact same mp3 file in the same code already playing but using a different library. So at least I know my mp3 is available for sound and properly setup. But I am wanting to use some of the capabilities of this library to see if it serve my purposes better. Thank you again.

@Darthmaul
Copy link

Hey thanks for the response @benvium ! I just did a clean xcode install on my brand new mac and the sound works fine. Not sure what was wrong, I guess switching to a new system worked.
Andrew

@n76i
Copy link

n76i commented Jul 17, 2018

did you try replace Sounddd.MAIN_BUNDLE with ''?

@paulmelnikow
Copy link
Collaborator

Hi! If you are still experiencing this issue in the latest version, could you please open an issue with more details following the issue template? Thanks!

@adancarrasco
Copy link

For iOS what worked for me is the following:

  1. Checked that my resource file was being played in xCode
  • Open xCode
  • Select the file
  • Click play in the xCode player
  1. Once it was playing sound (had issues with some files, possibly encoding),
  • Add the file as resource (Make sure is in Build Phases)
  1. Compile the project in xCode and run it from there
  • Note: Every time you change the resources or expect new resources you need to compile your Native application either by doing it from xCode or npm run ios

This is my code:

const sound = new Sound(
    "myFile.mp3",
    Sound.MAIN_BUNDLE,
    error => {
      if (error) {
        console.log("failed to load the sound", error);
        return;
      }
      sound.play(() => sound.release());
    }
  );
// The play dispatcher
sound.play();

@shindigital
Copy link

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.

@danghung24031992
Copy link

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.
I fixed it
https://github.com/danghung24031992/react-native-sound

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests