android - Fastest way to seek (skip) an inputstream with http protocol -
i making download service of sorts, , has ability resume previous partial download. using skip method this
long skipped = 0; while (skipped < track.getcachefile().length()){ skipped += is.skip(track.getcachefile().length()-skipped); }
i did test , took 57 seconds seconds skip 45 mb in inputstream. curious how native code this, instance, mediaplayer can seek part of remote stream instantaneously. realize not have access same libraries, can achieve similar.
btw, test on wifi. slower on normal data networks.
update: simple (thanks below)
if (track.getcachefile().length() > 0){ request.setheader("range","bytes="+track.getcachefile().length()+"-"); }
if using http protocol initiate inputstream, may try range header.
take here :
Comments
Post a Comment