diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-12-29 10:31:54 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-12-29 10:31:54 -0800 |
commit | 9da36cf4ffb2995f71f6e87a163f8f61c31cb050 (patch) | |
tree | 00f98a4af495c084810e44c81257eb0d6148becf /subsonic-android/src/github/daneren2005 | |
parent | bb2baacefc3b3fd44325b362883d8500cba3e6be (diff) | |
download | dsub-9da36cf4ffb2995f71f6e87a163f8f61c31cb050.tar.gz dsub-9da36cf4ffb2995f71f6e87a163f8f61c31cb050.tar.bz2 dsub-9da36cf4ffb2995f71f6e87a163f8f61c31cb050.zip |
Some devices are either not giving a bitrate, duration, or crashing on partialFile.getLength()
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java index 6f253d84..0f322817 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadFile.java @@ -257,8 +257,15 @@ public class DownloadFile { MusicService musicService = MusicServiceFactory.getMusicService(context); - // Attempt partial HTTP GET, appending to the file if it exists. - if((bitRate * song.getDuration() * 1000 / 8) > partialFile.length()) { + // Some devices seem to throw error on partial file which doesn't exist + boolean compare; + try { + compare = (bitRate == 0) || (song.getDuration() == 0) || (partialFile.length() == 0) || (bitRate * song.getDuration() * 1000 / 8) > partialFile.length(); + } catch(Exception e) { + compare = true; + } + if(compare) { + // Attempt partial HTTP GET, appending to the file if it exists. HttpResponse response = musicService.getDownloadInputStream(context, song, partialFile.length(), bitRate, DownloadTask.this); in = response.getEntity().getContent(); boolean partial = response.getStatusLine().getStatusCode() == HttpStatus.SC_PARTIAL_CONTENT; |