react-native-sound
安装:
1、npm install react-native-sound
2、react-native link react-native-sound //建议使用手动link
gihub地址:https://github.com/zmxv/react-native-sound
使用:
引入:import Sound from 'react-native-sound'
let sound= new Sound('sound.mp3', Sound.MAIN_BUNDLE, (error) => {
if (error) {
console.log('failed to load the sound', error);
return;
}
whoosh.play((success) => {
if (success) {
console.log('successfully');
} else {
console.log('errors');
}
});
});
设置:
1、play();//播放
2、stop();//停止
3、release();//释放
4、setSpeakerPhoneOn();//调整听筒和扬声器
5、loop();//循环播放