question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't load file on device

See original GitHub issue

Hi, I’m working on a simple soundboard app (source code is available at https://github.com/sexykodo/mlcSoundboard) that automatically fetches remote audio files according to a JSON and puts them in MainBundle with RNFetchBlob.

It’s something like this:

fetchRemoteFile = (obj) => {
        RNFetchBlob
            .config({
                path : RNFetchBlob.fs.dirs.MainBundleDir + encodeURI(obj.Path) //target path
            })
            .fetch('GET', MAIN_URL + encodeURI(obj.Path), {})
            .then((res) => {
                // the conversion is done in native code
                // the following conversions are done in js, it's SYNC
                console.log('The file saved to ', res.path())
            })
            // Status code is not 200
            .catch((errorMessage, statusCode) => {
                // error handling
                console.log(errorMessage)
            })
    }

In this way I can dynamically sync local files with remote ones (I want the soundboard to work offline). Everything works like a charm on IOS Simulator.

On physical device though, when I load the local file I get an errorcode “ENSOSSTATUSERRORDOMAIN2003334207”, wich is similar to #64 and probably caused by files not being included in Resources.

Is it actually possible to programmatically save an audio file (with RNFetchBlob) and play it?

Thanks in advance

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:28

github_iconTop GitHub Comments

26reactions
cooperkacommented, Feb 1, 2017

I was getting the same error when trying to play the file right away. This workaround fixes it for me (but it’s hacky). Both timeouts are necessary:

setTimeout(() => {
  var sound = new Sound(this.state.audioPath, '', (error) => {
    /* ... */
  });

  setTimeout(() => {
    sound.play((success) => {
      /* ... */
    });
  }, 100);
}, 100);
5reactions
MehdiJarrayacommented, Jun 7, 2018

@maurovisintin, thank you for your response. Your solution didn’t work for me but I figured out the problem and got it resolved this way: RNFetchBlob.config({ fileCache: true, })… when initializing the sound const sound = new Sound(file.Path,‘’, error => {… The sound bundle must be an empty string ‘’ in iOS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't open a Google file or folder - Android
On your Android device, open the app for Google Drive, Docs, Sheets, or Slides. · At the top left, tap Menu Menu ....
Read more >
Can't Open A File on Android? Here Are Steps You Can Take
What Possibly Can Be Done If You Can't Open A File On Android · 1. Check If Its A Genuine File Or A...
Read more >
Fix File Explorer if it won't open or start - Microsoft Support
To open File Explorer in Windows 11, select File Explorer on the taskbar or press the Windows logo key + E on your...
Read more >
Fixing 'Error in Loading Media: File Could Not Be Played'
Here are some easy solutions you can try to fix 'Error in Loading Media: File Could Not Be Played' on your Windows, Mac,...
Read more >
Android file viewer "cant load content at the moment" - Reddit
I fixed this by clearing the data of the Files app on a Galaxy Tab S4. Go to Settings > Apps > Show...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found