zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 748 forks source link

OSStatus error 1954115647 playing remote mp3 on iOS #448

Open chenweigh opened 6 years ago

chenweigh commented 6 years ago
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.

ishabo commented 5 years ago

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.

minhchienwikipedia commented 5 years ago

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

isaaclem commented 5 years ago

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

RWOverdijk commented 5 years ago

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.

dekameron22 commented 5 years ago

+1

SurajMDurgad commented 4 years ago

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];
  }
keval-ghorecha commented 2 years ago

any solution?

Coffeegerm commented 1 year ago

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

Coffeegerm commented 1 year ago

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

VinayakQubited commented 1 week ago

@Coffeegerm did u find any solution for .wav ??