Skip to content

Commit

Permalink
fix fetching content info (danikula#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
danikula committed Oct 29, 2015
1 parent 0264944 commit a270460
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {
jcenter()
}
dependencies {
compile 'com.danikula:videocache:2.3.2'
compile 'com.danikula:videocache:2.3.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ publish {
userOrg = 'alexeydanilov'
groupId = 'com.danikula'
artifactId = 'videocache'
publishVersion = '2.3.2'
publishVersion = '2.3.3'
description = 'Cache support for android VideoView'
website = 'https://github.com/danikula/AndroidVideoCache'
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public synchronized int length() throws ProxyCacheException {
@Override
public void open(int offset) throws ProxyCacheException {
try {
connection = openConnection(offset, "GET", -1);
connection = openConnection(offset, -1);
mime = connection.getContentType();
inputStream = new BufferedInputStream(connection.getInputStream(), DEFAULT_BUFFER_SIZE);
length = readSourceAvailableBytes(connection, offset, connection.getResponseCode());
Expand Down Expand Up @@ -99,7 +99,7 @@ private void fetchContentInfo() throws ProxyCacheException {
HttpURLConnection urlConnection = null;
InputStream inputStream = null;
try {
urlConnection = openConnection(0, "HEAD", 10000);
urlConnection = openConnection(0, 10000);
length = urlConnection.getContentLength();
mime = urlConnection.getContentType();
inputStream = urlConnection.getInputStream();
Expand All @@ -114,15 +114,14 @@ private void fetchContentInfo() throws ProxyCacheException {
}
}

private HttpURLConnection openConnection(int offset, String method, int timeout) throws IOException, ProxyCacheException {
private HttpURLConnection openConnection(int offset, int timeout) throws IOException, ProxyCacheException {
HttpURLConnection connection;
boolean redirected;
int redirectCount = 0;
String url = this.url;
do {
Log.d(LOG_TAG, "Open connection " + (offset > 0 ? " with offset " + offset : "") + " to " + url);
connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod(method);
if (offset > 0) {
connection.setRequestProperty("Range", "bytes=" + offset + "-");
}
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
// compile project(':library')
compile 'com.android.support:support-v4:23.1.0'
compile 'org.androidannotations:androidannotations-api:3.3.2'
compile 'com.danikula:videocache:2.3.2'
compile 'com.danikula:videocache:2.3.3'
compile 'com.viewpagerindicator:library:2.4.2-SNAPSHOT@aar'
apt 'org.androidannotations:androidannotations:3.3.2'
}

0 comments on commit a270460

Please sign in to comment.