[Android] Playing local files
See original GitHub issueI have tried this: <Video source={{uri: "/storage/emulated/0/test.mp4" }} ....
to no avail, and I was wondering if anyone has had any success playing local files on Android. If so, I would like to know how or if this is currently only available for iOS.
@buhe Is your pull request trying to fix this?
Thanks.
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (1 by maintainers)
Top Results From Across the Web
The 17 best music players on Android in 2022
Local players · Poweramp Music Player · foobar2000 · jetAudio HD Music Player · VLC for Android · AIMP.
Read more >Local files - Support - Spotify
Along with the millions of tracks we offer, the Local Files feature lets you use the Spotify app to play any other audio...
Read more >Google's YouTube Music can now play local files on Android
With local music integration, users who have music stored directly on their phones and SD card can now make use of YouTube music...
Read more >Your Android browser app is the easiest way to browse ...
Open local files via other browser apps · Launch the specific browser app that you want to use to browse through your files....
Read more >How To Add Local Files To Spotify On Android? - Reddit
On the computer, you go to Preferences -> Show Local Files. Then, Settings -> Show songs from -> [your files path]. Quit and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone stumbling upon this issue while trying to load local videos (i.e. native project assets rather than RN static resources), I have a few tips.
In my case, it was a matter of saving precious megabytes for CodePush updates. Indeed, when the videos are part of the RN project’s static resources, they will be included in the JS bundle sent to CodePush and retrieved by the users. I’ll let you do the calculation, but when you save more than 30 MB per update times 50k users, that counts! Not to mention the enhanced user experience.
To do so, you’ll first need to add the video files to your project:
mp4
files under the directoryandroid/app/src/main/res/raw
. Note that files in this directory must be lowercase and underscored (e.g.my_video.mp4
) and that subdirectories are not supported by Android.mp4
files to the project (right-click the project and select “Add Files to [PROJECTNAME]”). Subdirectories are supported by iOS.Then for the tricky part that cost me a lot of trials and errors:
<Video source={{ uri: 'my_video' }} />
<Video source={{ uri: 'my_video.mp4' }} />
I didn’t find this info anywhere so I thought it could help a frustrated dev or two 😉
When I created Lumpen Radio iOS app using this module a year ago I was able to store local video files under the project root folder in
src/assets/videos
. I was happy with this as I envisioned one day being able to leverage the same location for Android.During the Android support addition @isair mentioned video files for Android can be stored under
android/app/src/main/res/raw/
. While I’m extremely grateful for the Android support, the location specified seems less than ideal as it lends itself to duplication of video assets by platform.Poking through the open PRs I noticed this promising gem, which appears to allow one to leverage the RN asset system to do the resolving and help prevent by-platform file duplication or any kind of funky “cross-the-streams” loading of files for iOS from the Android raw sources folder.
Keywords storage location where to store android video
Related issues https://github.com/react-native-community/react-native-video/issues/246