0

I've made a desktop music player with create-nw-react-app. I'm using it to access flac files on my local machine, and play them through a simple audio ui. This was working fine until last night. I attempted to connect an external hd and use the app in the same way. I'm no longer able to access music files on my local or external hd, as the console now throws the following error:

GET file:///C:/Users/Ben/Desktop/Bootlegs/Rush/1977%20-%20A%20Farewell%20to%20Kings/10-12-77%20Canadian%20Bacon-PE/11%20Working%20Man.mp3 net::ERR_UNKNOWN_URL_SCHEME

Nothing in the code has changed, and I even went to the length of pulling it all down from my repo again. I'm thinking this is some kind of security issue, but I can't see any way to change it, and extensive Googling has yielded no results.

The basics of the code look like this:

<AudioPlayer
  className={pathLength === 5 ? classes.root : classes.rootFixed}
  autoPlayAfterSrcChange
  showSkipControls
  src={currentTracks[index]?.trackPath} />

The src is just a simple file path, none of which has changed. I've tried hard coding the file path into the src, but I still get the same error message.

Ben Jones
  • 1
  • 1
  • 2

1 Answers1

0

I believe this is behavior from React, not NW.js itself. Please see the following as an example of the correct way to import images/files into a React app:

Load local images in React.js

EDIT: Actually, it may be a security thing after all. The following is about Electron, but likely applies:

https://github.com/electron/electron/issues/23757

Maybe adding this to package.json would help:

{
  "chromium-args": "--allow-file-access-from-files"
}
sysrage
  • 594
  • 4
  • 6
  • Sadly, the standard way of importing doesn't really work, as the imports need to be entirely dynamic. There is a bit of a workaround for this, but it results in some fairly unpleasant re-renders. I tried your suggestion for the package.json, but to no avail. I'm totally stumped on this. – Ben Jones May 28 '21 at 20:03