The Androidvideocache is a video/audio cache library that uses local proxies to enable edge-to-bottom playback, which is very simple to use.
Httpproxycacheserver is the main class, is a proxy server, you can configure the number of cache files, the size of the cache file, the directory of cache files and the cache file naming algorithm, the file cache is based on the LRU algorithm, using Builder to configure:
// Builder cachedirectory (file file); // public Builder Filenamegenerator (Filenamegenerator filenamegenerator); // public Builder maxcachesize (long maxSize); // Configure the number of cache files public Builder Maxcachefilescount (int count);
It is recommended to store httpproxycacheserver in a single-column mode in application:
Public classAppextendsApplication {PrivateHttpproxycacheserver Proxy; Public StaticHttpproxycacheserver GetProxy (context context) {app app=(APP) context.getapplicationcontext (); returnApp.proxy = =NULL? (App.proxy =App.newproxy ()): App.proxy; } Privatehttpproxycacheserver Newproxy () {return NewHttpproxycacheserver ( This); }}
It is very convenient to call, just add one line of code:
@Override protected void onCreate (Bundle savedinstancestate) {super. OnCreate (savedinstancestate); = GetProxy (); = Proxy.getproxyurl (video_url); Videoview.setvideopath (Proxyurl);} Private httpproxycacheserver GetProxy () { return app.getproxy (Getapplicationcontext ());}
Android video/audio cache frame Androidvideocache