The Android SDK allows you to play media files that are stored locally on a device.
|Supported file format||.mp4|
When downloading videos from the web, opt for .mp4 conversions of the video asset. Streaming protocols like HLS or DASH have limited utility in an offline scenario and would require you to rewrite the manifest to account for the local segments.
|File path||Local path must use the |
To enable local content playback, use the following steps:
- Decide where the local media file is stored. On an Android device, local media files can be stored in either the /assets folder, /temp folder, or temp folder of your choice.
|/assets||• Media file is preloaded with the app|
• User selects a personal media file that already exists on the device
|/temp||Media file was downloaded from the internet when the device was last online|
You may want to use the Android Download Manager to download the video from the internet.
- Identify the absolute file path to the media file.
Accessing the local file system on Android will differ depending on which version of Android you are building against and your application's use case. To learn more about external file access on Android refer to the Android Data and file storage overview.
- Add the file path to a
mPlayerView = findViewById(R.id.jwplayer); PlaylistItem playlistItem = new PlaylistItem.Builder() .file("file:///local/path/file.mp4") .build(); List<PlaylistItem> playlist = new ArrayList<>(); playlist.add(playlistItem); PlayerConfig config = new PlayerConfig.Builder() .playlist(playlist) .build(); mPlayerView.setup(config);
Updated 8 days ago
Did this page help you?