React-native-track-player: Unable To Play Local Files

Created on 12 Nov 2018  路  9Comments  路  Source: react-native-kit/react-native-track-player

hi I am trying Sample Example In Android

With this PlayList.json Its Working Good:

[
{
"id": "4444",
"url": "https://drive.google.com/uc?export=download&id=1V-c_WmanMA9i5BwfkmTs-605BQDsfyzC",
"title": "Rhythm City (Demo)",
"artist": "David Chavez",
"artwork": "https://picsum.photos/200"
}
]

When I try To Add Some Local File Path in the json And try To play Its Not Working...

[
{
"id": "2222",
"url": "file:///storage/emulated/0/Download/Selena_Gomez_-_Naturally.mp3",
"title": "Soul Searching (Demo)",
"artist": "David Chavez",
"artwork": "https://picsum.photos/200"
},
{
"id": "4444",
"url": "https://drive.google.com/uc?export=download&id=1V-c_WmanMA9i5BwfkmTs-605BQDsfyzC",
"title": "Rhythm City (Demo)",
"artist": "David Chavez",
"artwork": "https://picsum.photos/200"
}
]

I Enabled Permissions.

Thanks In Advance...

Most helpful comment

@imran1992 dev branch is working try remove, node modules and android build folders from project and do npm i and build

and i guess RNFB.fs.dirs.DocumentDir Will have '/' in its path give it a shot with

url:"file://" + RNFB.fs.dirs.DocumentDir + "/myaudio.mp3"

All 9 comments

Please, try the latest dev branch.

And I want from app's files folder.
file:///storage/emulated/0/Android/data/com.myproject/files/audios/myaudio.mp3
How??
I am doing by
url:"file:///storage/emulated/0/Android/data/com.myproject/files/audios/myaudio.mp3".
Also Tried
url:"file:///" + RNFB.fs.dirs.DocumentDir + "/audios/myaudio.mp3", #227

@imran1992 dev branch is working try remove, node modules and android build folders from project and do npm i and build

and i guess RNFB.fs.dirs.DocumentDir Will have '/' in its path give it a shot with

url:"file://" + RNFB.fs.dirs.DocumentDir + "/myaudio.mp3"

@imran1992 dev branch is working try remove, node modules and android build folders from project and do npm i and build

and i guess RNFB.fs.dirs.DocumentDir Will have '/' in its path give it a shot with

url:"file://" + RNFB.fs.dirs.DocumentDir + "/myaudio.mp3"

OK. I downloaded Dev branch. And yes its working now....

Damn, I couldn't get it to work on the iPhone simulator today. I added the file:// prefix. But nothing to do. I downloaded the file with react-native-fs, don't know if it's related. I was on the dev branch. Everytime I add a new track the app crashes.

The file is downloaded, so it's not coming from the fs library...

If any one has an idea, do not hesitate.
Thanks

There was a really old issue about local files that the fix was to change from file:// to file:/// (three slashes instead of two), I don't know if that would work, but you should try that.

Hey ! Thanks for answering. I found out where it came from, what I did was
launch the app from xcode with the simulator so I could track the issue.
And I found it came from the MediaURL in Swift.

Basically what I had to do was use encodeURI on my localUrl. I had already
done that for the distantUrl before.

Didn't think about it...

But now it's working.

I also tried on Emulator but it doesn't work, it seems to work on a real device only

Was this page helpful?
0 / 5 - 0 ratings