在我的应用程序中,我有一个功能可以在收到消息时播放声音,它会通过播放声音文件来通知用户,该应用程序在 Android 中使用react-native-sound正常工作,但在 iOS 中我不断收到此错误:
我用于初始化声音的代码:
import Sound from "react-native-sound"
// Load the sound file 'whoosh.mp3' from the app bundle
// See notes below about preloading sounds within initialization code below.
var message_received = new Sound(require("../../res/audio/Page_Turn.mp3"), Sound.MAIN_BUNDLE, (error) => {
if (error) {
console.log('failed to load the sound', error);
return;
}
// loaded successfully
console.log('duration in seconds: ' + message_received.getDuration() + 'number of channels: ' + message_received.getNumberOfChannels());
});
我在初始化声音文件后调用的方法:
message_received.play()
有谁知道如何解决这个问题?