aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-10-03 20:18:51 -0700
committerScott Jackson <daneren2005@gmail.com>2013-10-03 20:18:51 -0700
commitb12723ce32014d338cf0ff288c3d19bf895cd891 (patch)
tree3abd7fcdd1843274c202060111b45530d3b7ce76 /src/github
parentbdd4f388beb8cce42a960887c6aeba459b201d4b (diff)
downloaddsub-b12723ce32014d338cf0ff288c3d19bf895cd891.tar.gz
dsub-b12723ce32014d338cf0ff288c3d19bf895cd891.tar.bz2
dsub-b12723ce32014d338cf0ff288c3d19bf895cd891.zip
Fix web commits
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadFile.java2
-rw-r--r--src/github/daneren2005/dsub/service/StreamProxy.java22
2 files changed, 16 insertions, 8 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java
index 4f79bdc9..b7dea72e 100644
--- a/src/github/daneren2005/dsub/service/DownloadFile.java
+++ b/src/github/daneren2005/dsub/service/DownloadFile.java
@@ -30,7 +30,7 @@ import android.os.PowerManager;
import android.util.DisplayMetrics;
import android.util.Log;
import github.daneren2005.dsub.domain.MusicDirectory;
-import github.daneren2005.service.parser.SubsonicRESTException;
+import github.daneren2005.dsub.service.parser.SubsonicRESTException;
import github.daneren2005.dsub.util.CancellableTask;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.Util;
diff --git a/src/github/daneren2005/dsub/service/StreamProxy.java b/src/github/daneren2005/dsub/service/StreamProxy.java
index f224e217..900a0c92 100644
--- a/src/github/daneren2005/dsub/service/StreamProxy.java
+++ b/src/github/daneren2005/dsub/service/StreamProxy.java
@@ -18,6 +18,7 @@ import java.net.URLDecoder;
import java.net.UnknownHostException;
import java.util.StringTokenizer;
+import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.apache.http.message.BasicHttpRequest;
@@ -164,13 +165,15 @@ public class StreamProxy implements Runnable {
Log.e(TAG, "File " + localPath + " does not exist");
return false;
}
-
+
// Use either partial or complete if downloading finished while StreamProxy was idle
file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile();
// Try to get range requested
- String range = request.getHeader("Range");
- if(range != null) {
+ Header rangeHeader = request.getFirstHeader("Range");
+
+ if(rangeHeader != null) {
+ String range = rangeHeader.getValue();
int index = range.indexOf("=");
if(index >= 0) {
range = range.substring(index + 1);
@@ -199,7 +202,7 @@ public class StreamProxy implements Runnable {
Integer contentLength = downloadFile.getContentLength();
if(contentLength == null && downloadFile.isWorkDone()) {
- contentLength = file.length();
+ contentLength = (int)file.length();
}
// Create HTTP header
@@ -207,13 +210,15 @@ public class StreamProxy implements Runnable {
if(cbSkip == 0) {
headers = "HTTP/1.0 200 OK\r\n";
} else {
- headers = "HTTP/1.0 206 OK\r\n;"
- headers += "Content-Range: bytes " + ckSkip + "-" + (file.length() - 1) + "/";
+ headers = "HTTP/1.0 206 OK\r\n;";
+ headers += "Content-Range: bytes " + cbSkip + "-" + (file.length() - 1) + "/";
if(contentLength == null) {
headers += "*";
} else {
headers += contentLength;
}
+
+ Log.i(TAG, "Streaming starts from: " + cbSkip);
}
headers += "Content-Type: " + "application/octet-stream" + "\r\n";
@@ -275,12 +280,15 @@ public class StreamProxy implements Runnable {
Thread.sleep(1000);
}
}
-
+
// Release file lock, use of stream proxy means nothing else is using it
downloadFile.setPlaying(false);
}
catch (SocketException socketException) {
Log.e(TAG, "SocketException() thrown, proxy client has probably closed. This can exit harmlessly");
+
+ // Release file lock, use of stream proxy means nothing else is using it
+ downloadFile.setPlaying(false);
}
catch (Exception e) {
Log.e(TAG, "Exception thrown from streaming task:");