I have a webview in android that goes to website that has a video tag in it. What would be the best way to either download the video or cache it so that it won't download every time it's being played. Couldn't find anything that works.
Download the video when you load it first time, and store it in your app's data folder. After that intercept the video url request in your webview and stream the video from local.
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
//Here check whether /request.getUrl().toString()/ is video url, if Yes, then
Get the locally saved video and convert it as inputstream and return as follows,
return new WebResourceResponse(getMimeType(request.getUrl().toString()), "UTF-8", 200, "OK", responseHeaders, inputStream);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With