question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Playing local files

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
bd-arccommented, Sep 28, 2021

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:

  • Android: Save your mp4 files under the directory android/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.
  • iOS: Open Xcode and add your 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:

  • Android: use the filename as the uri but don’t specify the file extension.
    • Example: <Video source={{ uri: 'my_video' }} />
  • iOS: it’s the exact opposite, meaning you need to specify the file extension.
    • Example: <Video source={{ uri: 'my_video.mp4' }} />

I didn’t find this info anywhere so I thought it could help a frustrated dev or two 😉

1reaction
ghostcommented, Aug 15, 2016

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found