Play Asset Delivery in React Native

375 views Asked by At

I have an app but it has a lot of video assets, in order to avoid not being able to upload to Google Play, I want to try to use Play Asset Delivery, but I can't find how to use it in React Native, I just want to separate the videos individually and use in JavaScript.

1

There are 1 answers

2
TheIrishPizzaGuy On

To access images from an install-time asset pack I followed this guide (faltutech blog article) up to settings.gradle. Then accessed the image via:

<Image
  source={{ uri: "asset:/myImage.png" }} //base directory of my_asset_pack/src/main/assets
  style={{ height: 100, width: 100 }}
></Image>

I found this solution digging around expo file system. There may be a more managed way of doing this (for both expo and non-expo) but this works.

For videos I imagine the same scheme works aswell, seeing as react-native-video also supports the uri convention

If you are in expo you will need to generate the android files with 'expo prebuild'