I have been trying to play the audio from a Youtube video (or .mp3 URL) in my React Native app. For my purposes, I cannot download the audio files to my device, they need to be streamed from the internet. I tried both Expo AV and React-Native-Sound-Player libraries but none were able to play the audio.
For testing the URL I am using is: https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3.
When I go to use the loadUrl() function in React-Native-Sound-Player, I get an error saying "Cannot read property 'loadUrl' of null". Same issue with play URL.
Does anyone have any experience streaming an audio from a URL in their apps? Is it even possible?
Any advice is appreciated.
Using this block of code to store the mp3 file in "currentSong" results in the error [TypeError: Cannot read property 'loadUrl' of null].
try {
currentSong = SoundPlayer.loadUrl('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3');
} catch (e) {
console.error(e);
I also tried using the react-native-video library and used the following code to no avail:
<Video source = {{uri: "https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"}}
ref={(ref) => {
this.player = ref
}} // Store reference
onBuffer={this.onBuffer} // Callback when remote video is buffering
onError={this.videoError} // Callback when video cannot be loaded
style = {styles.video} />
I get the following error: TypeError: Cannot read property 'Constants' of null