问题描述
我使用 Expo AV 并在我的应用程序中开发了一个屏幕来播放从我的服务器获取的音频文件.它在 Android 上运行良好,但在 iPhone 上无法播放.
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();
它返回一个错误:
不支持此媒体格式.- AVPlayerItem 实例失败,错误代码为 -11828,域为AVFoundationErrorDomain".
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();
}
}
我在录制和获取文件时尝试将音频格式更改为 m4a、wav、caf,但这没有帮助我在 iPhone 7 plus、iOS 14.2 上运行该应用程序请问有什么建议/修复吗?提前致谢
I have tried changing the audio format to m4a, wav, caf while recording and fetching the file but that did not help I'm running the app on iPhone 7 plus, iOS 14.2 Any suggestions/ fixes, please? Thanks in advance
推荐答案
我参加了 44 世博会,降级到 42 世博会成功了.运行 expo upgrade 42
.
I was on Expo 44, downgrading to Expo 42 did the trick. Run expo upgrade 42
.
这篇关于Expo AV 音频无法在 iOS/iPhone 上播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!