mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Reduce the amount of used data in background mode
This commit is contained in:
parent
2302515c26
commit
e021a52dbc
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user