zmxv / react-native-sound

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

Can't play audio from internal memory on IOS #658

Closed raphaelv619 closed 4 years ago

raphaelv619 commented 4 years ago

When I pull an audio from firebase, it plays normally, it is the same audio I recorded, but when I try to play this audio when it is in the internal memory of the phone, the play does not work, but I get a log of the correct duration the sound and also says it’s loaded, but it doesn’t play, and after I try to play an audio from the internal memory, the ones that come from firebase don’t play anymore

the filename from memory(_filename: '/var/mobile/Containers/Data/Application/438A07E6-8D46-4C5B-9533-B0778A74989D/Documents/audio.aac',)

this.sound = new Sound(filepath, ``, (error) => {
    if (error) {
           this.setState({ playState: 'paused' });
    } else {
           global.alert.alert(`duration ${this.sound.getDuration()}`)
           this.setState({ playState: 'playing', duration: this.sound.getDuration(), durState: 'playing' });
           this.sound.play(this.playComplete);
    }
 });

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

If your problem is happening on a device, which device?

YaoHuiJi commented 4 years ago

maybe this pr can help you

raphaelv619 commented 4 years ago

I really was not able to run the audio from the internal memory only on IOS using this plugin, so I made a workaround using the 'react-native-audio-toolkit' just to reproduce this type of audio, and for this to work I need to concatenate the prefix ' file: // 'before the IOS internal memory path