Hi i'm streaming video from a website in my android application. I have a history option showing the last seen videos. I wonder if i can use cache so that when the user enters the history the video is played faster (not downloaded again). When you use cache in Android does that mean that the whole video is downloaded and saved somewhere? or some data is saved somwhere(not the whole video).
Some help will be appreciated!!!
Thanks.
It should help you.
URLConnection cn = new URL(mediaUrl).openConnection();
cn.connect();
InputStream stream = cn.getInputStream();
File downloadingMediaFile = new File(context.getCacheDir(), "downloadingMedia.dat");
FileOutputStream out = new FileOutputStream(downloadingMediaFile);
byte buf[] = new byte[16384];
do {
int numread = stream.read(buf);
if (numread <= 0) break;
out.write(buf, 0, numread);
// ...
} while (...);
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