react-native-sound
How to stream an audio from url
[js]
var playSound = new Sound(‘your mp3 url’, null, (e) => {
if (e) {
console.log(‘error loading track:’, e)
} else {
playSound.play();
}
});
[/js]
How to stop audio being played and play the new audio every time new Webview is loaded
- Declare the react-native-sound variable as global variable
- Every time new Webview is loaded, get the new audio url, compare this with the playing url, if they are different, stop playing the current one to play the new one
react-native-track-player
How to download audio file
Install react-native-fs
[js]yarn add react-native-fs
react-native link react-native-fs
// Drag RNFS.xcodeproj into Xcode¥Libraries
[/js]
Leave a Reply