티스토리 뷰
패키지 추가
https://www.npmjs.com/package/react-native-sound-player
import SoundPlayer from 'react-native-sound-player';
안드로이드
사용할 음악 파일을 아래 경로에 위치 시킨다.
/android/app/src/main/res/raw/ring.mp3
아이폰
xCode 에서 위에 위치 시킨 파일을 스크린샷 처럼 추가 한다.
사용
try {
SoundPlayer.loadSoundFile('dial', 'mp3');
SoundPlayer.play();
} catch (e) {
console.log(`cannot play the sound file`, e)
}
공지사항