我正在开发 React Native,其版本为 0.74.5 版本。我还使用版本为 0.11.2 的 react-native-sound
库我几乎有一个空白项目。我愿意在按下 TouchableOpacity 组件时播放 mp3 文件。
我收到以下信息:ERROR TypeError: Cannot read property 'IsAndroid' of null, js engine: hermes on the console
我当前的 App.tsx 文件如下所示
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
import Sound from 'react-native-sound'
export default function App() {
Sound.setCategory('Playback')
return (
<View style={styles.container}>
<TouchableOpacity
style={{ backgroundColor: 'lightblue', padding: 10, borderRadius: 10 }}
onPress={() => {
console.log('test')
}}
>
<Text>Test 1 - Sonido</Text>
</TouchableOpacity>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
})
react-native-sound
好像没有维护了,上次更新是3年前了。我建议使用其他软件包,你可以尝试这些: