I have file picker pick audio file from local storage and , result of the file picker is as follows
size: 1057931
name: "AUD-20190314-WA0019.m4a"
type: "audio/mpeg"
uri: "content://com.android.externalstorage.documents/document/primary%3AWhatsApp%2FMedia%2FWhatsApp%20Audio%2FAUD-20190314-WA0019.m4a"
I am currently using react-native-sound for the playing the selected audio file from the picker
var whoosh = new Sound(audio, Sound.MAIN_BUNDLE, error => {
if (error) {
console.log('failed to load the sound', error);
return;
}
// loaded successfully
console.log(
'duration in seconds: ' +
whoosh.getDuration() +
'number of channels: ' +
whoosh.getNumberOfChannels(),
);
// Play the sound with an onEnd callback
whoosh.play(success => {
if (success) {
console.log('successfully finished playing');
} else {
console.log('playback failed due to audio decoding errors');
}
});
}
(audio variable is the uri revived in file picker)
But this approach doesn't play the audio file instead of playing , it leaves me the error
failed to load the sound {message: "resource not found", code: -1}
What am I doing wrong, and how can I be able to play the audio file picked form the file picker?