public class HttpProxyCacheServer
extends java.lang.Object
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.
}
| Modifier and Type | Class and Description |
|---|---|
static class |
HttpProxyCacheServer.Builder
Builder for
HttpProxyCacheServer. |
| Constructor and Description |
|---|
HttpProxyCacheServer(android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getProxyUrl(java.lang.String url)
Returns url that wrap original url and should be used for client (MediaPlayer, ExoPlayer, etc).
|
java.lang.String |
getProxyUrl(java.lang.String url,
boolean allowCachedFileUri)
Returns url that wrap original url and should be used for client (MediaPlayer, ExoPlayer, etc).
|
boolean |
isCached(java.lang.String url)
Checks is cache contains fully cached file for particular url.
|
void |
registerCacheListener(CacheListener cacheListener,
java.lang.String url) |
void |
shutdown() |
void |
unregisterCacheListener(CacheListener cacheListener) |
void |
unregisterCacheListener(CacheListener cacheListener,
java.lang.String url) |
public HttpProxyCacheServer(android.content.Context context)
public java.lang.String getProxyUrl(java.lang.String url)
If file for this url is fully cached (it means method isCached(String) returns true)
then file:// uri to cached file will be returned.
Calling this method has same effect as calling getProxyUrl(String, boolean) with 2nd parameter set to true.
url - a url to file that should be cached.public java.lang.String getProxyUrl(java.lang.String url,
boolean allowCachedFileUri)
If parameter allowCachedFileUri is true and file for this url is fully cached
(it means method isCached(String) returns true) then file:// uri to cached file will be returned.
url - a url to file that should be cached.allowCachedFileUri - true if allow to return file:// uri if url is fully cachedallowCachedFileUri is true).public void registerCacheListener(CacheListener cacheListener, java.lang.String url)
public void unregisterCacheListener(CacheListener cacheListener, java.lang.String url)
public void unregisterCacheListener(CacheListener cacheListener)
public boolean isCached(java.lang.String url)
url - an url cache file will be checked for.true if cache contains fully cached file for passed in parameters url.public void shutdown()