'How to Retrieve downloaded file to play React-native

I'm using react-native-fetch-blob to download the File . The File is residing at RNFS.DocumentDirectoryPath + fileExtension; eq: RNFS.DocumentDirectoryPath /myMusic.mp3;

the downloaded file is located at

/data/user/0/com.myproject/files/myMusic.mp3

and As per react-native-sound it is asking to place the files under raw folder. when I follow the below code using react-native-fs, Its Playing !!!!

downloadFileAndPlay()
    {
        console.log('Download');

        const downloadDest = RNFS.DocumentDirectoryPath + '/sample.mp3';
        const ret = RNFS.downloadFile(
            {
                fromUrl: 'http://www.julien-gustin.be/files/sample.mp3',
                toFile: downloadDest
            }
        );
        ret.promise.then(res => {
            console.log(res);
            // Load the sound file 'whoosh.mp3' from the app bundle
            // See notes below about preloading sounds within initialization code below.
            console.log(downloadDest);
            var whoosh = new Sound(downloadDest, '', (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());

                if(whoosh.isLoaded()){
                    console.log('LOADED');
                }else{
                    console.log('NOT LOADED');
                }

                // 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');
                    }
                });
            });

        }).catch(err => {
            console.log(err);
        });
    }

in both places I'am using the same Directory path . But in our case its not playing .. How can I retrieve the downloaded file and play While I am calling this file from another component?



Solution 1:[1]

This works for me, but with react-native-video

<Video
    source={{ uri: "file://" + RNFS.DocumentDirectoryPath + "/Claymore-OP01-NCBD.mp4" }} />

so basically, add the schema before the path:

file://somepath.mp3

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 madwyatt