-
public class HttpProxyCacheServerSimple lightweight proxy server with file caching support that handles HTTP requests. Typical usage:
public onCreate(Bundle state) { super.onCreate(state); HttpProxyCacheServer proxy = getProxy(); String proxyUrl = proxy.getProxyUrl(VIDEO_URL); videoView.setVideoPath(proxyUrl); } private HttpProxyCacheServer getProxy() { // should return single instance of HttpProxyCacheServer shared for whole app. }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classHttpProxyCacheServer.BuilderBuilder for HttpProxyCacheServer.
-
Constructor Summary
Constructors Constructor Description HttpProxyCacheServer(Context context)
-
Method Summary
Modifier and Type Method Description StringgetProxyUrl(String url)Returns url that wrap original url and should be used for client (MediaPlayer, ExoPlayer, etc). StringgetProxyUrl(String url, boolean allowCachedFileUri)Returns url that wrap original url and should be used for client (MediaPlayer, ExoPlayer, etc). voidregisterCacheListener(CacheListener cacheListener, String url)voidunregisterCacheListener(CacheListener cacheListener, String url)voidunregisterCacheListener(CacheListener cacheListener)booleanisCached(String url)Checks is cache contains fully cached file for particular url. voidshutdown()-
-
Constructor Detail
-
HttpProxyCacheServer
HttpProxyCacheServer(Context context)
-
-
Method Detail
-
getProxyUrl
String getProxyUrl(String url)
Returns url that wrap original url and should be used for client (MediaPlayer, ExoPlayer, etc).
If file for this url is fully cached (it means method isCached returns
{@code true})then file:// uri to cached file will be returned.Calling this method has same effect as calling getProxyUrl with 2nd parameter set to
{@code true}.- Parameters:
url- a url to file that should be cached.
-
getProxyUrl
String getProxyUrl(String url, boolean allowCachedFileUri)
Returns url that wrap original url and should be used for client (MediaPlayer, ExoPlayer, etc).
If parameter
{@code allowCachedFileUri}is{@code true}and file for this url is fully cached(it means method isCached returns{@code true}) then file:// uri to cached file will be returned.- Parameters:
url- a url to file that should be cached.allowCachedFileUri-{@code true}if allow to return file:// uri if url is fully cached
-
registerCacheListener
void registerCacheListener(CacheListener cacheListener, String url)
-
unregisterCacheListener
void unregisterCacheListener(CacheListener cacheListener, String url)
-
unregisterCacheListener
void unregisterCacheListener(CacheListener cacheListener)
-
isCached
boolean isCached(String url)
Checks is cache contains fully cached file for particular url.
- Parameters:
url- an url cache file will be checked for.
-
shutdown
void shutdown()
-
-
-
-