pull/32/head
kunfei 5 years ago
parent 430a444bf3
commit a2fa8e1adb
  1. 12
      app/src/main/java/io/legado/app/service/ReadAloudService.kt

@ -325,12 +325,14 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
* 初始化MediaSession, 注册多媒体按钮 * 初始化MediaSession, 注册多媒体按钮
*/ */
private fun initMediaSession() { private fun initMediaSession() {
val mComponent = ComponentName(packageName, MediaButtonReceiver::class.java.name) val mediaButtonIntent = Intent(Intent.ACTION_MEDIA_BUTTON).apply {
val mediaButtonIntent = Intent(Intent.ACTION_MEDIA_BUTTON) component = ComponentName(packageName, MediaButtonReceiver::class.java.name)
mediaButtonIntent.component = mComponent }
val mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast( val mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(
this, 0, this,
mediaButtonIntent, PendingIntent.FLAG_CANCEL_CURRENT 0,
mediaButtonIntent,
PendingIntent.FLAG_CANCEL_CURRENT
) )
mediaSessionCompat = MediaSessionCompat(this, tag) mediaSessionCompat = MediaSessionCompat(this, tag)

Loading…
Cancel
Save