mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Add max bitrate preference
This commit is contained in:
parent
730a578117
commit
560e7cc545
5 changed files with 55 additions and 0 deletions
|
|
@ -254,6 +254,52 @@ sealed interface AppPreference<T> {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private const val MEGA_BIT = 1024 * 1024L
|
||||||
|
const val DEFAULT_BITRATE = 20 * MEGA_BIT
|
||||||
|
private val bitrateValues =
|
||||||
|
listOf(
|
||||||
|
500 * 1024L,
|
||||||
|
750 * 1024L,
|
||||||
|
1 * MEGA_BIT,
|
||||||
|
2 * MEGA_BIT,
|
||||||
|
3 * MEGA_BIT,
|
||||||
|
5 * MEGA_BIT,
|
||||||
|
8 * MEGA_BIT,
|
||||||
|
10 * MEGA_BIT,
|
||||||
|
15 * MEGA_BIT,
|
||||||
|
DEFAULT_BITRATE,
|
||||||
|
*(30..100 step 10).map { it * MEGA_BIT }.toTypedArray(),
|
||||||
|
*(120..200 step 20).map { it * MEGA_BIT }.toTypedArray(),
|
||||||
|
)
|
||||||
|
val MaxBitrate =
|
||||||
|
AppSliderPreference(
|
||||||
|
title = R.string.max_bitrate,
|
||||||
|
defaultValue = bitrateValues.indexOf(DEFAULT_BITRATE).toLong(),
|
||||||
|
min = 0,
|
||||||
|
max = bitrateValues.size - 1L,
|
||||||
|
interval = 1,
|
||||||
|
getter = {
|
||||||
|
bitrateValues.indexOf(it.playbackPreferences.maxBitrate).toLong()
|
||||||
|
},
|
||||||
|
setter = { prefs, value ->
|
||||||
|
prefs.updatePlaybackPreferences {
|
||||||
|
maxBitrate = bitrateValues[value.toInt()]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
summarizer = { value ->
|
||||||
|
if (value != null) {
|
||||||
|
val v = bitrateValues.getOrNull(value.toInt()) ?: DEFAULT_BITRATE
|
||||||
|
if (v < MEGA_BIT) {
|
||||||
|
"${v / 1024} kbps"
|
||||||
|
} else {
|
||||||
|
"${v / MEGA_BIT} Mbps"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
val RememberSelectedTab =
|
val RememberSelectedTab =
|
||||||
AppSwitchPreference(
|
AppSwitchPreference(
|
||||||
title = R.string.remember_selected_tab,
|
title = R.string.remember_selected_tab,
|
||||||
|
|
@ -326,6 +372,7 @@ val basicPreferences =
|
||||||
AppPreference.AutoPlayNextUp,
|
AppPreference.AutoPlayNextUp,
|
||||||
AppPreference.AutoPlayNextDelay,
|
AppPreference.AutoPlayNextDelay,
|
||||||
AppPreference.SkipBackOnResume,
|
AppPreference.SkipBackOnResume,
|
||||||
|
AppPreference.MaxBitrate,
|
||||||
AppPreference.PlaybackDebugInfo,
|
AppPreference.PlaybackDebugInfo,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class AppPreferencesSerializer
|
||||||
AppPreference.AutoPlayNextDelay.defaultValue
|
AppPreference.AutoPlayNextDelay.defaultValue
|
||||||
skipBackOnResumeSeconds =
|
skipBackOnResumeSeconds =
|
||||||
AppPreference.SkipBackOnResume.defaultValue.seconds.inWholeMilliseconds
|
AppPreference.SkipBackOnResume.defaultValue.seconds.inWholeMilliseconds
|
||||||
|
maxBitrate = AppPreference.DEFAULT_BITRATE
|
||||||
}.build()
|
}.build()
|
||||||
homePagePreferences =
|
homePagePreferences =
|
||||||
HomePagePreferences
|
HomePagePreferences
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import androidx.media3.common.util.UnstableApi
|
||||||
import androidx.media3.exoplayer.ExoPlayer
|
import androidx.media3.exoplayer.ExoPlayer
|
||||||
import com.github.damontecres.dolphin.data.model.BaseItem
|
import com.github.damontecres.dolphin.data.model.BaseItem
|
||||||
import com.github.damontecres.dolphin.data.model.Chapter
|
import com.github.damontecres.dolphin.data.model.Chapter
|
||||||
|
import com.github.damontecres.dolphin.preferences.AppPreference
|
||||||
import com.github.damontecres.dolphin.preferences.UserPreferences
|
import com.github.damontecres.dolphin.preferences.UserPreferences
|
||||||
import com.github.damontecres.dolphin.ui.DefaultItemFields
|
import com.github.damontecres.dolphin.ui.DefaultItemFields
|
||||||
import com.github.damontecres.dolphin.ui.indexOfFirstOrNull
|
import com.github.damontecres.dolphin.ui.indexOfFirstOrNull
|
||||||
|
|
@ -267,6 +268,9 @@ class PlaybackViewModel
|
||||||
Timber.i("No change in playback for changeStreams")
|
Timber.i("No change in playback for changeStreams")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
val maxBitrate =
|
||||||
|
preferences.appPreferences.playbackPreferences.maxBitrate
|
||||||
|
.takeIf { it > 0 } ?: AppPreference.DEFAULT_BITRATE
|
||||||
val response =
|
val response =
|
||||||
api.mediaInfoApi
|
api.mediaInfoApi
|
||||||
.getPostedPlaybackInfo(
|
.getPostedPlaybackInfo(
|
||||||
|
|
@ -284,6 +288,7 @@ class PlaybackViewModel
|
||||||
autoOpenLiveStream = true,
|
autoOpenLiveStream = true,
|
||||||
mediaSourceId = null,
|
mediaSourceId = null,
|
||||||
alwaysBurnInSubtitleWhenTranscoding = null,
|
alwaysBurnInSubtitleWhenTranscoding = null,
|
||||||
|
maxStreamingBitrate = maxBitrate.toInt(),
|
||||||
),
|
),
|
||||||
).content
|
).content
|
||||||
val source = response.mediaSources.firstOrNull()
|
val source = response.mediaSources.firstOrNull()
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ message PlaybackPreferences {
|
||||||
bool auto_play_next = 6;
|
bool auto_play_next = 6;
|
||||||
int64 auto_play_next_delay_seconds = 7;
|
int64 auto_play_next_delay_seconds = 7;
|
||||||
int64 skip_back_on_resume_seconds = 8;
|
int64 skip_back_on_resume_seconds = 8;
|
||||||
|
int64 max_bitrate = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message HomePagePreferences{
|
message HomePagePreferences{
|
||||||
|
|
|
||||||
|
|
@ -61,5 +61,6 @@
|
||||||
<string name="confirm">Confirm</string>
|
<string name="confirm">Confirm</string>
|
||||||
<string name="remember_selected_tab">Remember selected tabs</string>
|
<string name="remember_selected_tab">Remember selected tabs</string>
|
||||||
<string name="director">Director</string>
|
<string name="director">Director</string>
|
||||||
|
<string name="max_bitrate">Max bitrate</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue