mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-09-17 06:52:27 +00:00
Hotfix playback speed for non-dot locales
This commit is contained in:
parent
4164b1a3f8
commit
19c84475db
1 changed files with 7 additions and 6 deletions
|
@ -174,6 +174,7 @@ import kotlinx.coroutines.sync.withLock
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import userpackage.Protocol
|
import userpackage.Protocol
|
||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
|
import java.util.Locale
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.roundToLong
|
import kotlin.math.roundToLong
|
||||||
|
|
||||||
|
@ -2192,19 +2193,19 @@ class VideoDetailView : ConstraintLayout {
|
||||||
if (canSetSpeed) SlideUpMenuButtonList(this.context, null, "playback_rate").apply {
|
if (canSetSpeed) SlideUpMenuButtonList(this.context, null, "playback_rate").apply {
|
||||||
val playbackSpeeds = Settings.instance.playback.getPlaybackSpeeds();
|
val playbackSpeeds = Settings.instance.playback.getPlaybackSpeeds();
|
||||||
val format = if(playbackSpeeds.size < 20) "%.2f" else "%.1f";
|
val format = if(playbackSpeeds.size < 20) "%.2f" else "%.1f";
|
||||||
val playbackLabels = playbackSpeeds.map { String.format(format, it) }.toMutableList();
|
val playbackLabels = playbackSpeeds.map { String.format(Locale.US, format, it) }.toMutableList();
|
||||||
playbackLabels.add("+");
|
playbackLabels.add("+");
|
||||||
playbackLabels.add(0, "-");
|
playbackLabels.add(0, "-");
|
||||||
|
|
||||||
setButtons(playbackLabels, String.format(format, currentPlaybackRate));
|
setButtons(playbackLabels, String.format(Locale.US, format, currentPlaybackRate));
|
||||||
onClick.subscribe { v ->
|
onClick.subscribe { v ->
|
||||||
val currentPlaybackSpeed = if (_isCasting) StateCasting.instance.activeDevice?.speed else _player.getPlaybackRate();
|
val currentPlaybackSpeed = if (_isCasting) StateCasting.instance.activeDevice?.speed else _player.getPlaybackRate();
|
||||||
var playbackSpeedString = v;
|
var playbackSpeedString = v;
|
||||||
val stepSpeed = Settings.instance.playback.getPlaybackSpeedStep();
|
val stepSpeed = Settings.instance.playback.getPlaybackSpeedStep();
|
||||||
if(v == "+")
|
if(v == "+")
|
||||||
playbackSpeedString = String.format("%.2f", Math.min((currentPlaybackSpeed?.toDouble() ?: 1.0) + stepSpeed, 5.0)).toString();
|
playbackSpeedString = String.format(Locale.US, "%.2f", Math.min((currentPlaybackSpeed?.toDouble() ?: 1.0) + stepSpeed, 5.0)).toString();
|
||||||
else if(v == "-")
|
else if(v == "-")
|
||||||
playbackSpeedString = String.format("%.2f", Math.max(0.1, (currentPlaybackSpeed?.toDouble() ?: 1.0) - stepSpeed)).toString();
|
playbackSpeedString = String.format(Locale.US, "%.2f", Math.max(0.1, (currentPlaybackSpeed?.toDouble() ?: 1.0) - stepSpeed)).toString();
|
||||||
val newPlaybackSpeed = playbackSpeedString.toDouble();
|
val newPlaybackSpeed = playbackSpeedString.toDouble();
|
||||||
if (_isCasting) {
|
if (_isCasting) {
|
||||||
val ad = StateCasting.instance.activeDevice ?: return@subscribe
|
val ad = StateCasting.instance.activeDevice ?: return@subscribe
|
||||||
|
@ -2212,11 +2213,11 @@ class VideoDetailView : ConstraintLayout {
|
||||||
return@subscribe
|
return@subscribe
|
||||||
}
|
}
|
||||||
|
|
||||||
qualityPlaybackSpeedTitle?.setTitle(context.getString(R.string.playback_rate) + " (${String.format("%.2f", newPlaybackSpeed)})");
|
qualityPlaybackSpeedTitle?.setTitle(context.getString(R.string.playback_rate) + " (${String.format(Locale.US, "%.2f", newPlaybackSpeed)})");
|
||||||
ad.changeSpeed(newPlaybackSpeed)
|
ad.changeSpeed(newPlaybackSpeed)
|
||||||
setSelected(playbackSpeedString);
|
setSelected(playbackSpeedString);
|
||||||
} else {
|
} else {
|
||||||
qualityPlaybackSpeedTitle?.setTitle(context.getString(R.string.playback_rate) + " (${String.format("%.2f", newPlaybackSpeed)})");
|
qualityPlaybackSpeedTitle?.setTitle(context.getString(R.string.playback_rate) + " (${String.format(Locale.US, "%.2f", newPlaybackSpeed)})");
|
||||||
_player.setPlaybackRate(playbackSpeedString.toFloat());
|
_player.setPlaybackRate(playbackSpeedString.toFloat());
|
||||||
setSelected(playbackSpeedString);
|
setSelected(playbackSpeedString);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue