react-native-sound icon indicating copy to clipboard operation
react-native-sound copied to clipboard

OSStatus error 1954115647 playing remote mp3 on iOS

Open chenweigh opened this issue 6 years ago • 9 comments

react-native-cli: 2.0.1
react-native: 0.50.1
react-native-sound": "^0.10.9

resource: https://www.cxy61.com/program_girl/media/007/cn/a1/792215b831cb7b9a6074ba5feac3fa6236115e.mp3

{
    code: "ENSOSSTATUSERRORDOMAIN1954115647",
    message: "The operation couldn’t be completed. (OSStatus error 1954115647.)",
    nativeStackIOS: Array(19),
    domain: "NSOSStatusErrorDomain",
    userInfo: {
        …
    }
}

how to fix issue? I need help.

chenweigh avatar Jun 20 '18 02:06 chenweigh

I have the same problem on IOS!

    const audio = new Sound(url, '', error => {
      console.warn(`Failed to load the sound ${url}`, error);
    });

I tried downloading the file first using fs and passing the full local path to the downloaded file but the same error! I have no issues on Android, it works perfectly.

ishabo avatar Aug 30 '18 19:08 ishabo

Anyone have an idea about that? I getting same issue play url on ios. Some url from another domain working as well.

minhchienwikipedia avatar Oct 09 '18 05:10 minhchienwikipedia

@chenweigh, @minhchienwikipedia : I faced the similar problem and managed to solve it. You need to add the sound file into Resources using XCode

isaaclem avatar Dec 03 '18 07:12 isaaclem

It's 2019 and we can't play audio from a remote url? 😄 Did anyone solve this? Any pointers? I don't mind making a PR.

RWOverdijk avatar May 21 '19 14:05 RWOverdijk

+1

dekameron22 avatar May 22 '19 11:05 dekameron22

This comment helped me out - https://stackoverflow.com/a/31244379/6660488 I was fetching mp3 files from the URLs. I think when you fetch the URL as data and provide it to AVAudioPlayer, sometimes there is an issue in the AVAudioPlayer to recognise the file format, OS considers it as unsupported file format.

I resolved the issue by adding fileTypeHint:AVFileTypeMPEGLayer3 to line 192 something like this in RNSound.m -

 if ([fileName hasPrefix:@"http"]) {
    fileNameUrl = [NSURL URLWithString:fileName];
    NSData* data = [NSData dataWithContentsOfURL:fileNameUrl];
    player = [[AVAudioPlayer alloc] initWithData:data fileTypeHint:AVFileTypeMPEGLayer3 error:&error];
  }

SurajMDurgad avatar Mar 04 '20 05:03 SurajMDurgad

any solution?

keval-ghorecha avatar May 21 '22 19:05 keval-ghorecha

Still seeing this issue on iOS for an s3 bucket .wav file. Able to fetch and play audio on Android though.

Coffeegerm avatar Sep 14 '22 14:09 Coffeegerm

After adding @SurajMDurgad change i now see that we are loading the sound correctly but I'm not able to play it, this is likely due to the difference that I'm trying to fetch .wav files and not mp3 files, checking into the other options for this

Coffeegerm avatar Sep 14 '22 14:09 Coffeegerm