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]
*/
private fun setMediaItem() {
streams?.let {
val uri = if (streams!!.hls != null) {
streams!!.hls
} else if (streams!!.audioStreams!!.isNotEmpty()) {
PlayerHelper.getAudioSource(
this,
streams!!.audioStreams!!
)
} else {
return
}
val mediaItem = MediaItem.Builder()
.setUri(uri)
.build()
player?.setMediaItem(mediaItem)
streams ?: return
val uri = if (streams!!.audioStreams.orEmpty().isNotEmpty()) {
PlayerHelper.getAudioSource(
this,
streams!!.audioStreams!!
)
} else if (streams!!.hls != null) {
streams!!.hls
} else {
return
}
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
binding.exoControlsBackground.setBackgroundColor(
if (isLocked) ContextCompat.getColor(
context,
com.google.android.exoplayer2.R.color.exo_black_opacity_60
) else Color.TRANSPARENT
if (isLocked) {
ContextCompat.getColor(
context,
com.google.android.exoplayer2.R.color.exo_black_opacity_60
)
} else {
Color.TRANSPARENT
}
)
// disable tap and swipe gesture if the player is locked