Home > front end >  File not found exception in react native
File not found exception in react native

Time:01-19

I am making a music player with react native. Some songs causes error because they have in their filenames. For example My music .mp3. I logged the filepath and it gave me something like file:///storage/emulated/0/xender/audio/My music .mp3. But when i try to play the music, it gives me an exception. The exception is h.f.c.d.t0.t$a: java.io.FileNotFoundException: storage/emulated/0/xender/audio/My music .mp3: open failed: ENOENT (No such file or directory). See!! The file path now has space instead of , and it is making it not to find the file. How can i fix that? I'm using React native expo-AV to play the music.

CodePudding user response:

is the HTML encoded value for space. When you get the file path, replacing the with a space might work.

var str = "HELLO WORLD";
alert(decodeURI(str))
  •  Tags:  
  • Related