Skip to content

Commit 0477674

Browse files
authored
android: set audiofocus none in popup video views (#611)
fixed popups interrupting media playback
1 parent c1093fb commit 0477674

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

android/app/src/main/java/me/kavishdevar/librepods/presentation/overlays/IslandWindow.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import android.content.IntentFilter
3333
import android.content.res.Resources
3434
import android.graphics.PixelFormat
3535
import android.graphics.drawable.GradientDrawable
36+
import android.media.AudioManager
3637
import android.os.Build
3738
import android.os.Handler
3839
import android.os.Looper
@@ -374,6 +375,7 @@ class IslandWindow(private val context: Context) {
374375

375376
val videoView = islandView.findViewById<VideoView>(R.id.island_video_view)
376377
val videoUri = "android.resource://me.kavishdevar.librepods/${R.raw.island}".toUri()
378+
videoView.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE)
377379
videoView.setVideoURI(videoUri)
378380
videoView.setOnPreparedListener { mediaPlayer ->
379381
mediaPlayer.isLooping = true

android/app/src/main/java/me/kavishdevar/librepods/presentation/overlays/PopupWindow.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import android.content.Context
2929
import android.content.Intent
3030
import android.content.IntentFilter
3131
import android.graphics.PixelFormat
32+
import android.media.AudioManager
3233
import android.os.Build
3334
import android.os.Handler
3435
import android.os.Looper
@@ -137,6 +138,7 @@ class PopupWindow(
137138
updateBatteryStatus(batteryNotification)
138139

139140
val vid = mView.findViewById<VideoView>(R.id.video)
141+
vid.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE)
140142
vid.setVideoPath("android.resource://me.kavishdevar.librepods/" + R.raw.connected)
141143
vid.resolveAdjustedSize(vid.width, vid.height)
142144
vid.start()

0 commit comments

Comments
 (0)