Sound.MAIN_BUNDLE: undefined - can't find file
See original GitHub issueI am using Android 5.01 React-native 0.19
after creating object to access my file
const notifySound = new Sound('notify.aac', Sound.MAIN_BUNDLE, (error) => {
I got error { message: 'resource not found', code: -1 }
I followed all steps in the documentation, but then console.log - Sound.MAIN_BUNDLE
and it’s undefined
{ [Function: Sound]
I/ReactNativeJS( 9413): enable: [Function],
I/ReactNativeJS( 9413): MAIN_BUNDLE: undefined,
I/ReactNativeJS( 9413): DOCUMENT: undefined,
I/ReactNativeJS( 9413): LIBRARY: undefined,
I/ReactNativeJS( 9413): CACHES: undefined }
which comes from sound.js
file and this code
Sound.MAIN_BUNDLE = RNSound.MainBundlePath;
Sound.DOCUMENT = RNSound.NSDocumentDirectory;
Sound.LIBRARY = RNSound.NSLibraryDirectory;
Sound.CACHES = RNSound.NSCachesDirectory;
Solution
In the end, I put my files into android/app/src/main/res/raw
, but it would be nice to put this file directly in my service folder
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
react-native-sound/Help - Gitter
MAIN_BUNDLE refers to android/app/src/main/res/raw directory which can be used to bundle sound files as the part of the APK itself but it increases...
Read more >Error in react native app 'failed to call function, __ ...
I believe the error arises when React can't find the main.jsbundle file in your app's main bundle at runtime.
Read more >How to use the react-native-sound.MAIN_BUNDLE function in ...
To help you get started, we've selected a few react-native-sound. ... forEach((s) => { // Load the sound file from the app bundle...
Read more >cannot read properties of undefined (reading 'path') multer ...
multer npm: TypeError: Cannot read property 'path' of undefined ... The path is throwing an error because "file" is not defined inside "req"...
Read more >@taoqf/react-native-fs - npm
require the module var RNFS = require('@taoqf/react-native-fs'); // get a list of files and directories in the main bundle RNFS.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For Android I got the same error if I try to reproduce a downloaded file. I got the example working ( putting the audio in /res/raw -> relative path) Everything works fine on IOS (simulator and physical device) if i put reproduce files from Sound.DOCUMENT
For Android i tried DocumentDir/MainBundleDir/DownloadDir but none of these seem to work. Library can’t seem to load the file from these sources. Any idea?
@fritx You’re right. I should probably check if
filename
is an absolute path in theif
condition.