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,22 +293,23 @@ 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) {
} else { streams!!.hls
return } else {
} return
val mediaItem = MediaItem.Builder()
.setUri(uri)
.build()
player?.setMediaItem(mediaItem)
} }
val mediaItem = MediaItem.Builder()
.setUri(uri)
.build()
player?.setMediaItem(mediaItem)
} }
/** /**

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) {
context, ContextCompat.getColor(
com.google.android.exoplayer2.R.color.exo_black_opacity_60 context,
) else Color.TRANSPARENT com.google.android.exoplayer2.R.color.exo_black_opacity_60
)
} else {
Color.TRANSPARENT
}
) )
// disable tap and swipe gesture if the player is locked // disable tap and swipe gesture if the player is locked