Demo not working using a url...
I have built the demo and it works. If I replace the line
const s = new Sound('advertising.mp3', Sound.MAIN_BUNDLE, (e) => {
with
const s = new Sound('https://api.example.com/tracks/test.mp3', '', (e) => {
I get the following error in the Android monitor:
Attempt to call getDuration without a valid mediaplayer
No error message from the demo code.
Should it be possible to use this module with urls anyway? (I read about the underscore things, but I am not using uppercase letters).
The above url is of course not my real one ;-)
Cheers
What's the real URL you're using?
This looks like a duplicate of #175. Currently it doesn't seem like it's able to play sounds from the network on android. I'm also having this issue and would love to know if it's going to be fixed or if anyone has a workaround.
you can use react-native-fetch-blob to download file audio with url and use react-native-sound to play. setTimeout(() => { RNFetchBlob .config({
fileCache: true,
})
.fetch('GET', 'url audio', {
})
.then((res) => {
var sound = new Sound(res.path(), '', (error) => {
if (error) {
}
});
setTimeout(() => {
sound.play((success) => {
if (success) {
} else {
}
});
}, 100);
})
}, 100);
I was having an issue playing larger sound files from the network (small files were fine) but using @katori216's suggestion of RNFetchBlob to download the file first works.
@jketcham I like this, but it seems a bit extreme for a demo. What if we add the example into documentation on the WIKI or have another example project.