【发布时间】:2022-11-19 01:24:36
【问题描述】:
大家好,我正在使用 Expo AV 在我的 React Native(Expo 管理的)应用程序中播放声音,音频在 android 上播放得很好而且听得见,但在 ios 上播放时声音不大听得见,苹果也拒绝了 App Store 上的应用程序因为这
他们说
您的应用在 Info.plist 的 UIBackgroundModes 键中声明支持音频,但不包含需要持久音频的功能。
下一步
音频密钥旨在供在后台向用户提供音频内容的应用程序使用,例如音乐播放器或流式音频应用程序。请修改您的应用程序以在应用程序处于后台时向用户提供音频内容,或者从 UIBackgroundModes 键中删除“音频”设置。这是 expo-av 音频模式设置
Audio.setAudioModeAsync({ staysActiveInBackground: true, shouldDuckAndroid: true, interruptionModeIOS: 1, interruptionModeAndroid: 1, allowsRecordingIOS: true, playsInSilentModeIOS: false, })我像这样播放音频
const {sound} = await Audio.Sound.createAsync( {uri: audioURI}, { shouldPlay: true, } );这是导入语句
import { Audio } from 'expo-av';我不知道它是否是由我在应用程序中用于音乐控件的 React Native Music Control 库引起的
像进口的
import MusicControl from 'react-native-music-control'我在播放音频后立即调用它
MusicControl.setNowPlaying({ title: currentAudio.title, artwork: currentAudio.imageUrl, // URL or RN's image require() artist: currentAudio.artist, genre: currentAudio.genre, duration: (minutesToMilliseconds(currentAudio.playtime) / 1000), // (Seconds) description: currentAudio.description, // Android Only color: 0xffffff, // Android Only - Notification Color colorized: true, // Android 8+ Only - Notification Color extracted from the artwork. Set to false to use the color property instead isLiveStream: false, // iOS Only (Boolean), Show or hide Live Indicator instead of seekbar on lock screen for live streams. Default value is false. })请问我做错了什么,在此先感谢您的帮助
【问题讨论】:
标签: ios react-native audio expo expo-av