mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 01:19:33 +00:00
Keep playing a voice message when the screen turns off
The ExoPlayer backing voice messages was built without a wake mode, so it defaulted to C.WAKE_MODE_NONE and held no wake lock. The CPU was free to suspend once the screen turned off, cutting playback short. Build it with C.WAKE_MODE_LOCAL instead. The media is a local file, so no WifiLock is needed, and android.permission.WAKE_LOCK is already in the merged manifest. The media viewer players are left alone: they already pause on ON_PAUSE, so a wake lock there would keep the CPU awake for a player the user has intentionally backgrounded.
This commit is contained in:
+2
-1
@@ -9,6 +9,7 @@
|
|||||||
package io.element.android.libraries.mediaplayer.impl
|
package io.element.android.libraries.mediaplayer.impl
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.media3.common.C
|
||||||
import androidx.media3.common.MediaItem
|
import androidx.media3.common.MediaItem
|
||||||
import androidx.media3.common.Player
|
import androidx.media3.common.Player
|
||||||
import androidx.media3.exoplayer.ExoPlayer
|
import androidx.media3.exoplayer.ExoPlayer
|
||||||
@@ -49,7 +50,7 @@ object SimplePlayerModule {
|
|||||||
@Provides
|
@Provides
|
||||||
fun simplePlayerProvider(
|
fun simplePlayerProvider(
|
||||||
@ApplicationContext context: Context,
|
@ApplicationContext context: Context,
|
||||||
): SimplePlayer = DefaultSimplePlayer(ExoPlayer.Builder(context).build())
|
): SimplePlayer = DefaultSimplePlayer(ExoPlayer.Builder(context).setWakeMode(C.WAKE_MODE_LOCAL).build())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user