Android assets
Is it possible to load file (both artwork & audio) from android assets? I'm receiving error "unexpected url: asset:/path/to/file/in/assets/file.jpg" for artwork, setting audio doesn't cause crash, but it's still not giving any sound
If you want to load a file from the app bundle, use require/import:
{
artwork: require('./file.jpg')
}
If you want to load a file from the file system, you can prepend file:/// to the path:
{
artwork: 'file:///path/to/file/file.jpg'
}
@Guichaguri thanks for quick reply, tried it with no luck, Android's assets folder really seems to be unsupported for now, since it needs different MediaPlayer data source handling, see react-native-sound I think using/handling the 'asset:/' prefix is just OK, I'll create PR soon
Why not use the app bundle instead? It basically works the same way as the assets folder
I'm closing this issue for inactivity. Feel free to reopen.
I am using something like this
{
artwork: this.props.player.currentTrack.img
}
where this.props.player.currentTrack.img is this for example:
file:///storage/emulated/0/com.myapp.app/covers/covers/covers783.jpg
but notification is still white and I can't get any images there. I was not able to find anything useful on documentation. Does anyone have any idea how to show local files in notification?
it appears a url like so works: file:///android_asset/path/to/file.mp3
Why not use the app bundle instead? It basically works the same way as the assets folder @Guichaguri, the app bundle will be load in startup time, if the file is large it will prolong the startup time when user opens the app, cause reducing UX.
@truongpham17 I have never experienced that. In Android, the files in the app bundle are moved to the assets folder and the import/require returns a reference ID to that Android asset. The only ones that prolong the startup time are JS or JSON files.