Question

I am developing an android application in which users can see the list of the videos in our database. All the videos are saved in Ooyala video platform.

Now when the user clicks on "download video" button, that video needs to be saved in the application cache. The user can view the video later at anytime. But I need it to be downloaded in the application cache itself, not in the library, so that the user can share that video easily.

So I created a local dababase in the application and saved the video lists.

But I am stuck here, in saving the cache area.

No correct solution

OTHER TIPS

I think this link might help you. You can use getCacheDir() for caching your video files. They will be stored in the internal storage of the app.

AndroidVideoCache allows to add caching support to your VideoView/MediaPlayer, ExoPlayer or any another player with following features:

  • caching to disk during streaming
  • offline work with cached resources
  • partial loading
  • cache limits (max cache size, max files count)
  • multiple clients for same url

You can use it in this way:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    HttpProxyCacheServer proxy = getProxy();
    String proxyUrl = proxy.getProxyUrl(VIDEO_URL);
    videoView.setVideoPath(proxyUrl);
}

For those of you looking for a Kotlin solution, check this library.

You just need to use

videoView.playUrl("https://your/video/file.mp4")

and the video will be automatically be saved to the local cache and played.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top