Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 17188

Expo AV audio not playing on iOS/ iPhone

$
0
0

I have used Expo AV and developed a screen in my app to play audio files fetched from my server. It works fine on Android, but doesn't play anything on iPhone.

When I play a button to play the audio which loads and plays the file

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 but that did not helpI'm running the app on iPhone 7 plus, iOS 14.2Any suggestions/ fixes, please? Thanks in advance


Viewing all articles
Browse latest Browse all 17188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>