aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-12-20 18:42:24 -0800
committerScott Jackson <daneren2005@gmail.com>2013-12-20 18:42:24 -0800
commit9f11830d6d5e1eb830952e825b6d6a223906e826 (patch)
tree5dfbc0d4ca7abd16127f78d53c7e86ade60cc285
parent269edd698348d00951c8e57cf16b54b1e59da827 (diff)
downloaddsub-9f11830d6d5e1eb830952e825b6d6a223906e826.tar.gz
dsub-9f11830d6d5e1eb830952e825b6d6a223906e826.tar.bz2
dsub-9f11830d6d5e1eb830952e825b6d6a223906e826.zip
Battery life improvements
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceImpl.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 51c32091..aaf8c533 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -977,7 +977,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
if(mediaPlayer != null && playerState == STARTED) {
cachedPosition = mediaPlayer.getCurrentPosition();
}
- Thread.sleep(200L);
+ Thread.sleep(1000L);
}
catch(Exception e) {
Log.w(TAG, "Crashed getting current position", e);
@@ -1272,25 +1272,26 @@ public class DownloadServiceImpl extends Service implements DownloadService {
Log.i(TAG, "Ending position " + pos + " of " + duration);
if (!isPartial || (downloadFile.isWorkDone() && (Math.abs(duration - pos) < 10000))) {
playNext();
- return;
+ } else {
+ // If file is not completely downloaded, restart the playback from the current position.
+ synchronized (DownloadServiceImpl.this) {
+ if(downloadFile.isWorkDone()) {
+ // Complete was called early even though file is fully buffered
+ Log.i(TAG, "Requesting restart from " + pos + " of " + duration);
+ reset();
+ downloadFile.setPlaying(false);
+ doPlay(downloadFile, pos, true);
+ downloadFile.setPlaying(true);
+ } else {
+ Log.i(TAG, "Requesting restart from " + pos + " of " + duration);
+ reset();
+ bufferTask = new BufferTask(downloadFile, pos);
+ bufferTask.start();
+ }
+ }
}
- // If file is not completely downloaded, restart the playback from the current position.
- synchronized (DownloadServiceImpl.this) {
- if(downloadFile.isWorkDone()) {
- // Complete was called early even though file is fully buffered
- Log.i(TAG, "Requesting restart from " + pos + " of " + duration);
- reset();
- downloadFile.setPlaying(false);
- doPlay(downloadFile, pos, true);
- downloadFile.setPlaying(true);
- } else {
- Log.i(TAG, "Requesting restart from " + pos + " of " + duration);
- reset();
- bufferTask = new BufferTask(downloadFile, pos);
- bufferTask.start();
- }
- }
+ wakeLock.release();
}
});
}