add background playback support for videos without an explicit audio source

Changelog: changed
This commit is contained in:
Kai 2025-01-14 11:36:37 -06:00
parent 891d3cf966
commit da58b72f9d
No known key found for this signature in database
2 changed files with 18 additions and 13 deletions

View file

@ -870,20 +870,18 @@ class VideoDetailView : ConstraintLayout {
}
_slideUpOverlay?.hide();
} else null,
if(!isLimitedVersion)
RoundButton(context, R.drawable.ic_screen_share, context.getString(R.string.background), TAG_BACKGROUND) {
if(!allowBackground) {
_player.switchToAudioMode();
allowBackground = true;
it.text.text = resources.getString(R.string.background_revert);
}
else {
_player.switchToVideoMode();
allowBackground = false;
it.text.text = resources.getString(R.string.background);
}
_slideUpOverlay?.hide();
if (!isLimitedVersion) RoundButton(context, R.drawable.ic_screen_share, if (allowBackground) context.getString(R.string.background_revert) else context.getString(R.string.background), TAG_BACKGROUND) {
if (!allowBackground) {
_player.switchToAudioMode();
allowBackground = true;
it.text.text = resources.getString(R.string.background_revert);
} else {
_player.switchToVideoMode();
allowBackground = false;
it.text.text = resources.getString(R.string.background);
}
_slideUpOverlay?.hide();
}
else null,
if(!isLimitedVersion)
RoundButton(context, R.drawable.ic_download, context.getString(R.string.download), TAG_DOWNLOAD) {

View file

@ -298,6 +298,12 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
builder = builder.setMaxAudioBitrate(_targetTrackAudioBitrate);
}
builder = if (isAudioMode) {
builder.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, true)
} else {
builder.setTrackTypeDisabled(C.TRACK_TYPE_VIDEO, false)
}
val trackSelector = exoPlayer?.player?.trackSelector;
if(trackSelector != null) {
trackSelector.parameters = builder.build();
@ -737,6 +743,7 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
val sourceAudio = _lastAudioMediaSource;
val sourceSubs = _lastSubtitleMediaSource;
updateTrackSelector()
beforeSourceChanged();