Browse Source

Merge branch 'bugfix/120-bluetooth-buttons-unresponsive' into 'develop'

Fix Bluetooth control button unresponsiveness.

Closes #120

See merge request funkwhale/funkwhale-android!171
technical/upgrade-exoplayer
Ryan Harg 2 years ago
parent
commit
9cac0e9aed
  1. 15
      app/src/main/java/audio/funkwhale/ffa/playback/MediaSession.kt
  2. 1
      changes/changelog.d/120.bugfix

15
app/src/main/java/audio/funkwhale/ffa/playback/MediaSession.kt

@ -2,6 +2,7 @@ package audio.funkwhale.ffa.playback
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.ResultReceiver import android.os.ResultReceiver
import android.support.v4.media.session.MediaSessionCompat import android.support.v4.media.session.MediaSessionCompat
@ -44,13 +45,17 @@ class MediaSession(private val context: Context) {
it.setMediaButtonEventHandler { _, _, intent -> it.setMediaButtonEventHandler { _, _, intent ->
if (!active) { if (!active) {
context.startService( Intent(context, PlayerService::class.java).let { player ->
Intent(context, PlayerService::class.java).apply { player.action = intent.action
action = intent.action
intent.extras?.let { extras -> putExtras(extras) } intent.extras?.let { extras -> player.putExtras(extras) }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(player)
} else {
context.startService(player)
}
} }
)
return@setMediaButtonEventHandler true return@setMediaButtonEventHandler true
} }

1
changes/changelog.d/120.bugfix

@ -0,0 +1 @@
Fix unresponsive bluetooth buttons with Oreo and later (thanks @hdash)
Loading…
Cancel
Save