- npm install react-native-sound --save react-native link react-native-sound
- Add file "yoursound.mp3" to Resources folder in iOS XCode project
-
import Sound from "react-native-sound";
-
constructor(props) { super(props); Sound.setCategory("Playback"); mSound = new Sound("yoursound.mp3", Sound.MAIN_BUNDLE); }
-
_playSound() { mSound.play(success => { if (success) { console.log("Success"); } else { console.log("Failure"); mSound.reset(); } }); }
- Created by HuyHung Dinh
- GitHub: https://github.com/hu2di
- Email: hebitaxy@gmail.com