首页 > 解决方案 > Some audio url not playing on ios react native

问题描述

Im building a react native application which plays audio file from url(internet).

From the admin side we are providing 2 options. (upload audio and record audio).

Using react-mic on the admin side for recording audio.

The issue is the audio files which we upload is getting played properly in react native android and ios.(https://s3.eu-west-3.amazonaws.com/evolum/beginner_1.mp3)

But the recorded audio using react-mic is getting played in android but not in ios.(https://learnpodseditornodeserver.knomadixapp.com/b2748b8d36e12478e2d99ff6c04492a2.mp3)

I'm using react-native-sound to play audio on mobile.

Here's my code

const sound = new Sound(audioUrl, '', (error) => {
                  if (error) {
                    console.log('failed to load the sound', error); // this error
                    return;
                  }
                  // Play the sound with an onEnd callback
                  sound.play((success) => {
                    if (success) {
                      console.log('successfully finished playing');
                    } else {
                      console.log('playback failed due to audio decoding errors');
                    }
                  });
                });

Here's the error i'm getting.

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

标签: iosreactjsreact-nativeaudio

解决方案


尝试从初始化中删除 ''

const sound = new Sound(audioUrl, error => {
  
});

推荐阅读