I am using Expo AV to play audio files fetched from my server URI. - WHICH IS NOT WORKING
It only play files locally saved / project folder but not from the URI
It works fine on Android though
When I call the function which loads and plays the file from URI- soundObject.loadAsync({ uri: this.state.file }); soundObject.playAsync();
it returns an error :This media format is not supported. - The AVPlayerItem instance has failed with the error code -11828 and domain “AVFoundationErrorDomain”.
Here is my code that loads and plays the audio :
async loadAudio() {
soundObject = new Audio.Sound();
try {
await soundObject.loadAsync({ uri: this.state.file });
console.log("File loaded: " + this.state.file);
} catch (error) {
console.log(error);
}
}
async playAudio() {
if (!this.state.isPlayingAudio) {
try {
await soundObject.playAsync();
} catch (error) {
console.log(error);
}
else {
soundObject.pauseAsync();
}
I have tried changing the audio format to m4a, wav, caf while recording and fetching the file from URI , but that did not help.
Locally saved file in any format plays well though.
I need to play from file from URI
Any suggestions/ fixes, please? Thanks in advance
Expo CLI 3.28.2 environment info:
System:
OS: Windows 10 10.0.17763
Binaries:
Node: 12.13.0 - C:\Users\DELL\AppData\Roaming\npm\node.CMD
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.7 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6626763
npmPackages:
expo: ~40.0.0 => 40.0.0
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2
react-native-web: ~0.13.12 => 0.13.18
Expo Workflow: managed