pull/1259/head
gedoor 3 years ago
parent fbb6b88832
commit 9e57896260
  1. 16
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt

@ -68,7 +68,7 @@ abstract class BaseReadAloudService : BaseService(),
initBroadcastReceiver() initBroadcastReceiver()
upNotification() upNotification()
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
handler.postDelayed(dsRunnable, 60000) startDs()
} }
override fun onDestroy() { override fun onDestroy() {
@ -148,6 +148,7 @@ abstract class BaseReadAloudService : BaseService(),
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED) upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED)
postEvent(EventBus.ALOUD_STATE, Status.PAUSE) postEvent(EventBus.ALOUD_STATE, Status.PAUSE)
ReadBook.uploadProgress() ReadBook.uploadProgress()
startDs()
} }
@CallSuper @CallSuper
@ -182,7 +183,7 @@ abstract class BaseReadAloudService : BaseService(),
private fun setTimer(minute: Int) { private fun setTimer(minute: Int) {
timeMinute = minute timeMinute = minute
upNotification() startDs()
} }
private fun addTimer() { private fun addTimer() {
@ -192,6 +193,12 @@ abstract class BaseReadAloudService : BaseService(),
timeMinute += 10 timeMinute += 10
if (timeMinute > 180) timeMinute = 180 if (timeMinute > 180) timeMinute = 180
} }
startDs()
}
private fun startDs() {
handler.removeCallbacks(dsRunnable)
handler.postDelayed(dsRunnable, 60000)
postEvent(EventBus.TTS_DS, timeMinute) postEvent(EventBus.TTS_DS, timeMinute)
upNotification() upNotification()
} }
@ -201,9 +208,10 @@ abstract class BaseReadAloudService : BaseService(),
*/ */
private fun doDs() { private fun doDs() {
if (!pause) { if (!pause) {
if (timeMinute > 0) { if (timeMinute >= 0) {
timeMinute-- timeMinute--
} else if (timeMinute == 0) { }
if (timeMinute == 0) {
stopSelf() stopSelf()
} }
} }

Loading…
Cancel
Save