Reduce the amount of used data in background mode

This commit is contained in:
Bnyro 2023-01-08 15:54:48 +01:00
parent 2302515c26
commit e021a52dbc
2 changed files with 24 additions and 19 deletions

View File

@ -293,23 +293,24 @@ class BackgroundMode : Service() {
* Sets the [MediaItem] with the [streams] into the [player] * Sets the [MediaItem] with the [streams] into the [player]
*/ */
private fun setMediaItem() { private fun setMediaItem() {
streams?.let { streams ?: return
val uri = if (streams!!.hls != null) {
streams!!.hls val uri = if (streams!!.audioStreams.orEmpty().isNotEmpty()) {
} else if (streams!!.audioStreams!!.isNotEmpty()) {
PlayerHelper.getAudioSource( PlayerHelper.getAudioSource(
this, this,
streams!!.audioStreams!! streams!!.audioStreams!!
) )
} else if (streams!!.hls != null) {
streams!!.hls
} else { } else {
return return
} }
val mediaItem = MediaItem.Builder() val mediaItem = MediaItem.Builder()
.setUri(uri) .setUri(uri)
.build() .build()
player?.setMediaItem(mediaItem) player?.setMediaItem(mediaItem)
} }
}
/** /**
* fetch the segments for SponsorBlock * fetch the segments for SponsorBlock

View File

@ -323,10 +323,14 @@ internal class CustomExoPlayerView(
// hide the dimming background overlay if locked // hide the dimming background overlay if locked
binding.exoControlsBackground.setBackgroundColor( binding.exoControlsBackground.setBackgroundColor(
if (isLocked) ContextCompat.getColor( if (isLocked) {
ContextCompat.getColor(
context, context,
com.google.android.exoplayer2.R.color.exo_black_opacity_60 com.google.android.exoplayer2.R.color.exo_black_opacity_60
) else Color.TRANSPARENT )
} else {
Color.TRANSPARENT
}
) )
// disable tap and swipe gesture if the player is locked // disable tap and swipe gesture if the player is locked