pull/34/head
kunfei 5 years ago
parent b3e6451d5c
commit c0779256e2
  1. 6
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  2. 1
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  3. 5
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt

@ -189,7 +189,11 @@ abstract class BaseReadAloudService : BaseService(),
} ?: stopSelf() } ?: stopSelf()
} }
abstract fun play() open fun play() {
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
postEvent(Bus.ALOUD_STATE, Status.PLAY)
upNotification()
}
@CallSuper @CallSuper
open fun pauseReadAloud(pause: Boolean) { open fun pauseReadAloud(pause: Boolean) {

@ -74,6 +74,7 @@ class HttpReadAloudService : BaseReadAloudService(),
override fun onPrepared(mp: MediaPlayer?) { override fun onPrepared(mp: MediaPlayer?) {
mp?.start() mp?.start()
super.play()
} }
override fun onError(mp: MediaPlayer?, what: Int, extra: Int): Boolean { override fun onError(mp: MediaPlayer?, what: Int, extra: Int): Boolean {

@ -7,7 +7,6 @@ import android.support.v4.media.session.PlaybackStateCompat
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.Bus import io.legado.app.constant.Bus
import io.legado.app.constant.Status
import io.legado.app.help.IntentHelp import io.legado.app.help.IntentHelp
import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefInt import io.legado.app.utils.getPrefInt
@ -67,9 +66,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
return return
} }
if (requestFocus()) { if (requestFocus()) {
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) super.play()
postEvent(Bus.ALOUD_STATE, Status.PLAY)
upNotification()
for (i in nowSpeak until contentList.size) { for (i in nowSpeak until contentList.size) {
if (i == 0) { if (i == 0) {
speak(contentList[i], TextToSpeech.QUEUE_FLUSH, AppConst.APP_TAG + i) speak(contentList[i], TextToSpeech.QUEUE_FLUSH, AppConst.APP_TAG + i)

Loading…
Cancel
Save