[Android] Check metered upon playing stream
Nicolas Pomepuy
git at videolan.org
Wed May 15 13:56:43 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed May 15 10:00:29 2024 +0200| [1248ff4f1f2a998a245fc0e55b0b72f19c93f142] | committer: Nicolas Pomepuy
Check metered upon playing stream
> https://code.videolan.org/videolan/vlc-android/commit/1248ff4f1f2a998a245fc0e55b0b72f19c93f142
---
application/vlc-android/src/org/videolan/vlc/PlaybackService.kt | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 8288067251..f197f38379 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -309,6 +309,11 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
if (!wakeLock.isHeld) wakeLock.acquire()
showNotification()
nbErrors = 0
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ NetworkConnectionManager.isMetered.value?.let {
+ checkMetered(it)
+ }
+ }
}
MediaPlayer.Event.Paused -> {
if (BuildConfig.DEBUG) Log.i(TAG, "MediaPlayer.Event.Paused")
@@ -768,7 +773,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
}
}
- private fun checkMetered(metered: Boolean, activity: Activity? = null) {
+ private fun checkMetered(metered: Boolean) {
if (!metered) return
val meteredAction = (settings.getString("metered_connection", "0") ?: "0").toInt()
if (meteredAction != 0 && isSchemeStreaming(currentMediaLocation)) {
More information about the Android
mailing list