Skip to content

Commit

Permalink
add max count & update exo_player2 2.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Oct 26, 2020
1 parent eb8faeb commit 1ca7bbd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ext {

gsyVideoVersion = '7.1.6'

exo_player2 = '2.11.3'
exo_player2 = '2.12.1'

permissionsdispatcher = '4.3.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public class ProxyCacheManager implements ICacheManager, CacheListener {

public static int DEFAULT_MAX_SIZE = 512 * 1024 * 1024;
public static int DEFAULT_MAX_COUNT = -1;

//视频代理
protected HttpProxyCacheServer proxy;
Expand Down Expand Up @@ -162,7 +163,11 @@ public HttpProxyCacheServer newProxy(Context context, File file) {
}
HttpProxyCacheServer.Builder builder = new HttpProxyCacheServer.Builder(context);
builder.cacheDirectory(file);
builder.maxCacheSize(DEFAULT_MAX_SIZE);
if (DEFAULT_MAX_COUNT > 0) {
builder.maxCacheFilesCount(DEFAULT_MAX_COUNT);
} else {
builder.maxCacheSize(DEFAULT_MAX_SIZE);
}
builder.headerInjector(userAgentHeadersInjector);
if (fileNameGenerator != null) {
builder.fileNameGenerator(fileNameGenerator);
Expand All @@ -179,9 +184,16 @@ public void setProxy(HttpProxyCacheServer proxy) {
* 创建缓存代理服务
*/
public HttpProxyCacheServer newProxy(Context context) {
return new HttpProxyCacheServer.Builder(context.getApplicationContext())
.maxCacheSize(DEFAULT_MAX_SIZE)
.headerInjector(userAgentHeadersInjector).build();
HttpProxyCacheServer.Builder builder = new HttpProxyCacheServer
.Builder(context.getApplicationContext())
.headerInjector(userAgentHeadersInjector);
if (DEFAULT_MAX_COUNT > 0) {
builder.maxCacheFilesCount(DEFAULT_MAX_COUNT);
} else {
builder.maxCacheSize(DEFAULT_MAX_SIZE);
}
return builder.build();

}


Expand Down

0 comments on commit 1ca7bbd

Please sign in to comment.