Merge branch 'playback-stutter-fix' into 'master'

background playback stutter fix

See merge request videostreaming/grayjay!103
This commit is contained in:
Kai DeLorenzo 2025-06-04 20:44:09 +00:00
commit 8ca317a38a
4 changed files with 13 additions and 9 deletions

View file

@ -487,11 +487,6 @@ class Settings : FragmentedStorageFileJson() {
@FormField(R.string.live_chat_webview, FieldForm.TOGGLE, R.string.use_the_live_chat_web_window_when_available_over_native_implementation, 9)
var useLiveChatWindow: Boolean = true;
@FormField(R.string.background_switch_audio, FieldForm.TOGGLE, R.string.background_switch_audio_description, 10)
var backgroundSwitchToAudio: Boolean = true;
@FormField(R.string.restart_after_audio_focus_loss, FieldForm.DROPDOWN, R.string.restart_playback_when_gaining_audio_focus_after_a_loss, 11)
@DropdownFieldOptionsId(R.array.restart_playback_after_loss)
var restartPlaybackAfterLoss: Int = 1;

View file

@ -1115,7 +1115,7 @@ class VideoDetailView : ConstraintLayout {
when (Settings.instance.playback.backgroundPlay) {
0 -> handlePause();
1 -> {
if(!(video?.isLive ?: false) && Settings.instance.playback.backgroundSwitchToAudio)
if(!(video?.isLive ?: false))
_player.switchToAudioMode();
StatePlayer.instance.startOrUpdateMediaSession(context, video);
}

View file

@ -252,12 +252,22 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
fun switchToVideoMode() {
Logger.i(TAG, "Switching to Video Mode");
isAudioMode = false;
loadSelectedSources(playing, true);
val player = exoPlayer ?: return
player.player.trackSelectionParameters =
player.player.trackSelectionParameters
.buildUpon()
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, isAudioMode)
.build()
}
fun switchToAudioMode() {
Logger.i(TAG, "Switching to Audio Mode");
isAudioMode = true;
loadSelectedSources(playing, true);
val player = exoPlayer ?: return
player.player.trackSelectionParameters =
player.player.trackSelectionParameters
.buildUpon()
.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, isAudioMode)
.build()
}
fun seekTo(ms: Long) {

View file

@ -429,7 +429,6 @@
<string name="seek_offset">Seek duration</string>
<string name="seek_offset_description">Fast-Forward / Fast-Rewind duration</string>
<string name="background_switch_audio">Switch to Audio in Background</string>
<string name="background_switch_audio_description">Optimize bandwidth usage by switching to audio-only stream in background if available, may cause stutter</string>
<string name="subscription_group_menu">Groups</string>
<string name="show_subscription_group">Show Subscription Groups</string>
<string name="use_subscription_exchange">Use Subscription Exchange (Experimental)</string>