Expo AV 音频无法在 iOS/iPhone 上播放

Expo AV audio not playing on iOS/ iPhone(Expo AV 音频无法在 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 上播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)