diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-01-19 08:40:09 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-01-19 08:40:09 -0800 |
commit | 9835dedc90ea55ecbc01aeaa6ea6cba61c8d57d3 (patch) | |
tree | 0c92f8203577ce796026878c883e1e8f3c454182 /subsonic-android/src/github/daneren2005 | |
parent | 000624b796755a2edf18f66101c0bef0aa6fba4e (diff) | |
download | dsub-9835dedc90ea55ecbc01aeaa6ea6cba61c8d57d3.tar.gz dsub-9835dedc90ea55ecbc01aeaa6ea6cba61c8d57d3.tar.bz2 dsub-9835dedc90ea55ecbc01aeaa6ea6cba61c8d57d3.zip |
Added Buffer Length option
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
3 files changed, 12 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java index fa57fc53..18d7e6b4 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java @@ -60,6 +60,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer private ListPreference preloadCount; private EditTextPreference randomSize; private ListPreference tempLoss; + private EditTextPreference bufferLength; @Override public void onCreate(Bundle savedInstanceState) { @@ -77,6 +78,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer preloadCount = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT); randomSize = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_RANDOM_SIZE); tempLoss = (ListPreference) findPreference(Constants.PREFERENCES_KEY_TEMP_LOSS); + bufferLength = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_BUFFER_LENGTH); findPreference("testConnection1").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override @@ -167,6 +169,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer preloadCount.setSummary(preloadCount.getEntry()); randomSize.setSummary(randomSize.getText()); tempLoss.setSummary(tempLoss.getEntry()); + bufferLength.setSummary(bufferLength.getText() + " seconds"); for (ServerSettings ss : serverSettings.values()) { ss.update(); } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 68aa228f..8c12372c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -1109,9 +1109,6 @@ public class DownloadServiceImpl extends Service implements DownloadService { } private class BufferTask extends CancellableTask { - - private static final int BUFFER_LENGTH_SECONDS = 5; - private final DownloadFile downloadFile; private final int position; private final long expectedFileSize; @@ -1122,9 +1119,16 @@ public class DownloadServiceImpl extends Service implements DownloadService { this.position = position; partialFile = downloadFile.getPartialFile(); + SharedPreferences prefs = Util.getPreferences(DownloadServiceImpl.this); + long bufferLength = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_BUFFER_LENGTH, "5")); + if(bufferLength == 0) { + // Set to seconds in a day, basically infinity + bufferLength = 86400L; + } + // Calculate roughly how many bytes BUFFER_LENGTH_SECONDS corresponds to. int bitRate = downloadFile.getBitRate(); - long byteCount = Math.max(100000, bitRate * 1024 / 8 * BUFFER_LENGTH_SECONDS); + long byteCount = Math.max(100000, bitRate * 1024L / 8L * bufferLength); // Find out how large the file should grow before resuming playback. Log.i(TAG, "Buffering from position " + position + " and bitrate " + bitRate); diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index bf344fe6..4dac8d4c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -86,6 +86,7 @@ public final class Constants { public static final String PREFERENCES_KEY_SHUFFLE_END_YEAR = "endYear"; public static final String PREFERENCES_KEY_SHUFFLE_GENRE = "genre"; public static final String PREFERENCES_KEY_KEEP_SCREEN_ON = "keepScreenOn"; + public static final String PREFERENCES_KEY_BUFFER_LENGTH = "bufferLength"; // Name of the preferences file. public static final String PREFERENCES_FILE_NAME = "github.daneren2005.dsub_preferences"; |