Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read the video from android asset folder #2825

Closed
t104360088 opened this issue Aug 23, 2022 · 6 comments · Fixed by #3733
Closed

Read the video from android asset folder #2825

t104360088 opened this issue Aug 23, 2022 · 6 comments · Fixed by #3733

Comments

@t104360088
Copy link

I must to read the video from android asset folder, so using require or putting the video in android/raw doesn't suit my needs.
I know this issue has been reported, but it doesn't seem to actually fix it. Hope someone can help me, thanks.

Below are the paths I've tried, but unfortunately none of them work.

source={{ uri: 'file:///android_asset/test.mp4' }}
source={{ uri: 'asset:/test.mp4' }}

Related References:
Using file path in react-native-video
Path of Android asset folder
The same issue but he fix it by adjusting source code
Read the video from android raw folder but not my case

The same issue:
#2096, #1826

@rohitsingh2410
Copy link

rohitsingh2410 commented Aug 31, 2022

try like require('../../assets/video.mp4')

<Video ref={(ref) => { this.player = ref }} source={videoURL} style={{ position: 'relative', top: 0, left: 0, bottom: 0, right: 0, width:"100%",height:"100%", }} />

@t104360088
Copy link
Author

t104360088 commented Sep 1, 2022

try like require('../../assets/video.mp4')

<Video ref={(ref) => { this.player = ref }} source={videoURL} style={{ position: 'relative', top: 0, left: 0, bottom: 0, right: 0, width:"100%",height:"100%", }} />

Thank you for your answer, but please clarify my problem first, my file is not in the top-level directory, but in the compiled asset directory of android. Your answer is for files placed in the top-level directory.

@freeboub
Copy link
Collaborator

freeboub commented Sep 3, 2022

According java code, it asset:// should be a valid uri to use it. but I didn't find the 'full' implementation (I was expecting specific implementation).
As a workaround you should be able to use file:///data/data//test.mp4
But depending on installation place of the app this path can change...

According to this:
https://stackoverflow.com/questions/51853695/play-video-with-exoplayer-through-a-folder-in-the-assets-folder

You can also try to use the uri asset:///test.mp4

Please let me know if you find a solution.

@freeboub freeboub added Platform: Android triage needed Help needed to confirm the issue labels Sep 3, 2022
@freeboub
Copy link
Collaborator

did you try with : assets-library:// ?

@evoactivity
Copy link
Contributor

This will need a new loader adding to support loading files from assets.

An example of this being done in exoplayer can be seen here

We'd essentially want to add a detection for an asset:// type and add a new loader here https://github.com/react-native-video/react-native-video/blob/66b2ba3fcfd4efb7863530da76950ba397ebde85/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java#L722

@t104360088
Copy link
Author

@freeboub I tried the way you provided, but unfortunately it doesn't work

@freeboub freeboub self-assigned this Mar 29, 2024
@freeboub freeboub added feature and removed triage needed Help needed to confirm the issue labels May 4, 2024
@freeboub freeboub removed their assignment May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants