[expo-av] allow playing media files from apk res folder #8936
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
ref #8888 -- expo-av currently does not support playing media files from an android apk's
res/raw
folder, which is where the RN packager embeds required assets by default.How
RN's asset source resolver sets the
uri
for assets embedded inres
to simply the resource name with no scheme. Therefore, if the url provided to expo-av has no scheme, we can assume it comes from RN's asset source resolver and is a resource name. (We do the same thing in expo-file-system.)Found a couple of sources for how to read from resources in
MediaPlayer
andExoPlayer
(but I am no expert on either library!).Test Plan
Tested using the repo provided in #8888 and confirmed that with expo-updates disabled, after this change, the audio file played as expected both with ExoPlayer and with
androidImplementation: 'MediaPlayer'
.