Expo AV audio not playing on iOS/ iPhone(Expo AV 音频无法在 iOS/iPhone 上播放)
问题描述
我使用 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 上播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Expo AV 音频无法在 iOS/iPhone 上播放
基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01