无法读取 null / (react-native-sound) 的属性“IsAndroid”

问题描述 投票:0回答:1

我正在开发 React Native,其版本为 0.74.5 版本。我还使用版本为 0.11.2react-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',
    },
})
android react-native audio hermes
1个回答
0
投票

react-native-sound
好像没有维护了,上次更新是3年前了。我建议使用其他软件包,你可以尝试这些:

© www.soinside.com 2019 - 2024. All rights reserved.