diff --git a/app/src/main/java/io/legado/app/help/MediaHelp.kt b/app/src/main/java/io/legado/app/help/MediaHelp.kt index 377fd5fbd..d2de56c2d 100644 --- a/app/src/main/java/io/legado/app/help/MediaHelp.kt +++ b/app/src/main/java/io/legado/app/help/MediaHelp.kt @@ -2,10 +2,17 @@ package io.legado.app.help import android.content.Context import android.media.MediaPlayer +import android.support.v4.media.session.PlaybackStateCompat import io.legado.app.R object MediaHelp { - + const val MEDIA_SESSION_ACTIONS = (PlaybackStateCompat.ACTION_PLAY + or PlaybackStateCompat.ACTION_PAUSE + or PlaybackStateCompat.ACTION_PLAY_PAUSE + or PlaybackStateCompat.ACTION_SKIP_TO_NEXT + or PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS + or PlaybackStateCompat.ACTION_STOP + or PlaybackStateCompat.ACTION_SEEK_TO) fun playSilentSound(mContext: Context) { try { diff --git a/app/src/main/java/io/legado/app/service/ReadAloudService.kt b/app/src/main/java/io/legado/app/service/ReadAloudService.kt index bd48eefed..f1d4d61cb 100644 --- a/app/src/main/java/io/legado/app/service/ReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/ReadAloudService.kt @@ -30,13 +30,6 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage companion object { val tag: String = ReadAloudService::class.java.simpleName var isRun = false - const val MEDIA_SESSION_ACTIONS = (PlaybackStateCompat.ACTION_PLAY - or PlaybackStateCompat.ACTION_PAUSE - or PlaybackStateCompat.ACTION_PLAY_PAUSE - or PlaybackStateCompat.ACTION_SKIP_TO_NEXT - or PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS - or PlaybackStateCompat.ACTION_STOP - or PlaybackStateCompat.ACTION_SEEK_TO) fun paly(context: Context, title: String, body: String) { @@ -224,7 +217,7 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManage private fun upMediaSessionPlaybackState() { mediaSessionCompat?.setPlaybackState( PlaybackStateCompat.Builder() - .setActions(MEDIA_SESSION_ACTIONS) + .setActions(MediaHelp.MEDIA_SESSION_ACTIONS) .setState( if (speak) PlaybackStateCompat.STATE_PLAYING else PlaybackStateCompat.STATE_PAUSED, nowSpeak.toLong(), 1f