mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
feat: implemented streaming buffering strategy
This commit is contained in:
parent
9fde629233
commit
0a5983e32b
5 changed files with 36 additions and 3 deletions
|
|
@ -42,6 +42,7 @@ object Preferences {
|
|||
private const val SHARE = "share"
|
||||
private const val SCROBBLING = "scrobbling"
|
||||
private const val ESTIMATE_CONTENT_LENGTH = "estimate_content_length"
|
||||
private const val BUFFERING_STRATEGY = "buffering_strategy"
|
||||
|
||||
@JvmStatic
|
||||
fun getServer(): String? {
|
||||
|
|
@ -331,4 +332,10 @@ object Preferences {
|
|||
fun askForEstimateContentLength(): Boolean {
|
||||
return App.getInstance().preferences.getBoolean(ESTIMATE_CONTENT_LENGTH, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBufferingStrategy(): Double {
|
||||
return App.getInstance().preferences.getString(BUFFERING_STRATEGY, "1")!!.toDouble()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -211,4 +211,17 @@
|
|||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="buffering_strategy_titles">
|
||||
<item>Minimum</item>
|
||||
<item>Moderate</item>
|
||||
<item>Aggressive</item>
|
||||
<item>Extreme</item>
|
||||
</string-array>
|
||||
<string-array name="buffering_strategy_values">
|
||||
<item>.1</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>4</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
|
@ -236,6 +236,8 @@
|
|||
<string name="settings_audio_transcode_priority_summary">If enabled, Tempo will not force stream the track with the transcode settings below.</string>
|
||||
<string name="settings_audio_transcode_priority_title">Prioritize server transcode settings</string>
|
||||
<string name="settings_audio_transcode_priority_toast">Priority on transcoding of track given to server</string>
|
||||
<string name="settings_buffering_strategy">Buffering strategy</string>
|
||||
<string name="settings_buffering_strategy_summary">For the change to take effect you must manually restart the app.</string>
|
||||
<string name="settings_covers_cache">Size of artwork cache</string>
|
||||
<string name="settings_data_saving_mode_summary">In order to reduce data consumption, avoid downloading covers.</string>
|
||||
<string name="settings_data_saving_mode_title">Limit mobile data usage</string>
|
||||
|
|
|
|||
|
|
@ -102,6 +102,16 @@
|
|||
android:summary="@string/settings_sync_starred_tracks_for_offline_use_summary"
|
||||
android:key="sync_starred_tracks_for_offline_use" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="1"
|
||||
app:dialogTitle="@string/settings_buffering_strategy"
|
||||
app:entries="@array/buffering_strategy_titles"
|
||||
app:entryValues="@array/buffering_strategy_values"
|
||||
app:key="buffering_strategy"
|
||||
app:title="@string/settings_buffering_strategy"
|
||||
app:summary="@string/settings_buffering_strategy_summary"
|
||||
app:useSimpleSummaryProvider="false" />
|
||||
|
||||
<Preference
|
||||
android:key="download_storage"
|
||||
app:title="@string/settings_download_storage_title" />
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.cappielloantonio.tempo.R
|
|||
import com.cappielloantonio.tempo.ui.activity.MainActivity
|
||||
import com.cappielloantonio.tempo.util.Constants
|
||||
import com.cappielloantonio.tempo.util.DownloadUtil
|
||||
import com.cappielloantonio.tempo.util.Preferences
|
||||
import com.cappielloantonio.tempo.util.ReplayGainUtil
|
||||
import com.google.android.gms.cast.framework.CastContext
|
||||
import com.google.android.gms.common.ConnectionResult
|
||||
|
|
@ -208,7 +209,7 @@ class MediaService : MediaLibraryService(), SessionAvailabilityListener {
|
|||
.setAudioAttributes(AudioAttributes.DEFAULT, true)
|
||||
.setHandleAudioBecomingNoisy(true)
|
||||
.setWakeMode(C.WAKE_MODE_NETWORK)
|
||||
// .setLoadControl(initializeLoadControl())
|
||||
.setLoadControl(initializeLoadControl())
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
@ -296,8 +297,8 @@ class MediaService : MediaLibraryService(), SessionAvailabilityListener {
|
|||
private fun initializeLoadControl(): DefaultLoadControl {
|
||||
return DefaultLoadControl.Builder()
|
||||
.setBufferDurationsMs(
|
||||
60_000,
|
||||
120_000,
|
||||
(DefaultLoadControl.DEFAULT_MIN_BUFFER_MS * Preferences.getBufferingStrategy()).toInt(),
|
||||
(DefaultLoadControl.DEFAULT_MAX_BUFFER_MS * Preferences.getBufferingStrategy()).toInt(),
|
||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
|
||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue