We are creating a sound effect playback app with Expo (React Native).
I'm trying to make it by referring to the Expo official document, but here, I'm importing the mp3 file as a require function.
Code for the Expo official document. (https://docs.expo.io/versions/latest/sdk/audio/)
const soundObject = new Audio.Sound();
try {
await soundObject.loadAsync(require('./assets/sounds/hello.mp3'));
await soundObject.playAsync();
// // Your sound is playing!
} } catch (error) {
}
It's my code.
var testPng = require('./assets/test.png')
var testMp3 = require('./assets/test.mp3')
console.log(testPng)
console.log(testMp3)
Unable to resolve "./assets/test.mp3" from "App.js"
undefined Unable to resolve module ./assets/test.mp3
from App.js
:
None of these files exist:
node.js react-native javascript
It was resolved by reinstalling node.js with the latest version.
© 2024 OneMinuteCode. All rights reserved.