jsierles / react-native-audio

Audio recorder library for React Native
MIT License
1.16k stars 537 forks source link

Recorded AAC audio in Android, won't play in iOS devices #161

Open maulikvora opened 7 years ago

maulikvora commented 7 years ago

AAC audio recorded in Android is not playing in iOS devices. Here is the code example how we are recording the audio in Android device. When we try to play that audio in iOS device using react-native-sound, It won't play and shows error like this.

Failed to load the sound and iOS exception read as below. Objectcode: "ENSOSSTATUSERRORDOMAIN1937337955"domain: "NSOSStatusErrorDomain"message: "The operation couldn't be completed. (OSStatus error 1937337955.)"nativeStackIOS: Array[17]userInfo: Object__proto__: Object

AudioRecorder.prepareRecordingAtPath('/path/to/audio/test.aac', {
        SampleRate: 22050,
        Channels: 1,
        AudioQuality: "Low",
        AudioEncoding: "aac",
        AudioEncodingBitRate: 32000
      });

We are using RN 0.41 and react-native-audio 3.2.1

DId anyone face similar issue? let me know if there is any misconfiguration.

BilalYazbek commented 7 years ago

I am facing the same issue right now using RN 0.41.2 and react-native-audio 3.2.1. It would be really helpful if someone could identify the problem

BilalYazbek commented 7 years ago

In my code it was solved in JS this way: if (Platform.OS === 'ios') { Sound.enable(true); } before initializing the new sound. Hope this is helpful.

maulikvora commented 7 years ago

@BilalYazbek we are already doing this.

We can successfully play audio recorded in ioS. but if audio is recorded in Android, it won't play on iOS. we are using same library for both Android & iOS

rakannimer commented 7 years ago

Could you please provide the code you're using to play the recording on both android and ios ?

TaoHenry commented 7 years ago

npm install --save react-native-sound@0.10.1 can solve this problem

zmGitHub commented 7 years ago

+1

wayne1203 commented 7 years ago

I got the same issue, but I'm in opposite. Record AAC from iOS but not able to play in Android. I found that the sample app AAC(pew2.aac) is MPEG ADTS, AAC, v4 LC, 44.1 kHz, stereo and the aac record in iOS is MPEG ADTS, AAC, v2 LC, 44.1 kHz, stereo

Hope that can help~

minhtc commented 6 years ago

I have fixed this issue by adding option 'OutputFormat' like bellow:

 AudioRecorder.prepareRecordingAtPath(newFilePath, {
      SampleRate: 22050,
      Channels: 1,
      AudioQuality: 'Low',
      AudioEncoding: 'aac',
      OutputFormat: 'aac_adts',
    })

I think the example code has missing information .

castielLi commented 6 years ago

@minhtc i valued OutputFormat "aac_adts" but still not work , i found that iOS support AAC since iOS3, i also found someone set OutputFormat as "three_gpp" in Android native to make iOS play record well.

Ble3k commented 6 years ago

Same issue, nothing from above didn't help

sidharthd commented 6 years ago

I had a similar problem. Recording and playback were working on iOS simulator, but not on iOS device. Following @BilalYazbek and setting

if (Platform.OS === 'ios') { Sound.enable(true); }

solved the problem.

PS: Haven't tested on Android.

leiz-me commented 5 years ago

I am facing something similar but not the same. Can anyone help?

299