我使用了 react-native-sound 和 react-native-audio-recorder-player 等库来播放数组中的曲目。我尝试映射数组,但它只播放第一首曲目。有什么方法可以让我一个接一个地播放阵列中的所有曲目吗?
const[id, setId] = useState(1)
const sound = new Sound(('/data/user/0/com.hay/cache/' + id + '.mp3'), Sound.MAIN_BUNDLE)
const playA = () => {
sound.play(success=> setId(id+1))
}
return (
<View style={{flex: 1, backgroundColor: '#FFEDCB', justifyContent: 'center'}}>
<View style={{alignSelf: 'center'}} >
<Image source={globo} style={{width: 340, height: 484}} />
<View style={{ position: 'absolute', top: 403 }}>
<View style={{flexDirection: 'row',position: 'absolute', right: -120 }}>
<TouchableOpacity onPress={()=>playA() }
style={styles.iconHeart}><Icon name={ 'play-circle-outline'}
size={60} color='#F8C56A' /></TouchableOpacity>
</View></View></View></View>
);
};