|
|
@ -7,7 +7,7 @@ import io.legado.app.service.BaseReadAloudService |
|
|
|
import io.legado.app.service.TTSReadAloudService |
|
|
|
import io.legado.app.service.TTSReadAloudService |
|
|
|
|
|
|
|
|
|
|
|
object ReadAloud { |
|
|
|
object ReadAloud { |
|
|
|
|
|
|
|
var aloudClass = TTSReadAloudService::class.java |
|
|
|
|
|
|
|
|
|
|
|
fun play( |
|
|
|
fun play( |
|
|
|
context: Context, |
|
|
|
context: Context, |
|
|
@ -17,7 +17,7 @@ object ReadAloud { |
|
|
|
dataKey: String, |
|
|
|
dataKey: String, |
|
|
|
play: Boolean = true |
|
|
|
play: Boolean = true |
|
|
|
) { |
|
|
|
) { |
|
|
|
val readAloudIntent = Intent(context, TTSReadAloudService::class.java) |
|
|
|
val readAloudIntent = Intent(context, aloudClass) |
|
|
|
readAloudIntent.action = Action.play |
|
|
|
readAloudIntent.action = Action.play |
|
|
|
readAloudIntent.putExtra("title", title) |
|
|
|
readAloudIntent.putExtra("title", title) |
|
|
|
readAloudIntent.putExtra("subtitle", subtitle) |
|
|
|
readAloudIntent.putExtra("subtitle", subtitle) |
|
|
@ -29,7 +29,7 @@ object ReadAloud { |
|
|
|
|
|
|
|
|
|
|
|
fun pause(context: Context) { |
|
|
|
fun pause(context: Context) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
val intent = Intent(context, TTSReadAloudService::class.java) |
|
|
|
val intent = Intent(context, aloudClass) |
|
|
|
intent.action = Action.pause |
|
|
|
intent.action = Action.pause |
|
|
|
context.startService(intent) |
|
|
|
context.startService(intent) |
|
|
|
} |
|
|
|
} |
|
|
@ -37,7 +37,7 @@ object ReadAloud { |
|
|
|
|
|
|
|
|
|
|
|
fun resume(context: Context) { |
|
|
|
fun resume(context: Context) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
val intent = Intent(context, TTSReadAloudService::class.java) |
|
|
|
val intent = Intent(context, aloudClass) |
|
|
|
intent.action = Action.resume |
|
|
|
intent.action = Action.resume |
|
|
|
context.startService(intent) |
|
|
|
context.startService(intent) |
|
|
|
} |
|
|
|
} |
|
|
@ -45,7 +45,7 @@ object ReadAloud { |
|
|
|
|
|
|
|
|
|
|
|
fun stop(context: Context) { |
|
|
|
fun stop(context: Context) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
val intent = Intent(context, TTSReadAloudService::class.java) |
|
|
|
val intent = Intent(context, aloudClass) |
|
|
|
intent.action = Action.stop |
|
|
|
intent.action = Action.stop |
|
|
|
context.startService(intent) |
|
|
|
context.startService(intent) |
|
|
|
} |
|
|
|
} |
|
|
@ -53,7 +53,7 @@ object ReadAloud { |
|
|
|
|
|
|
|
|
|
|
|
fun prevParagraph(context: Context) { |
|
|
|
fun prevParagraph(context: Context) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
val intent = Intent(context, TTSReadAloudService::class.java) |
|
|
|
val intent = Intent(context, aloudClass) |
|
|
|
intent.action = Action.prevParagraph |
|
|
|
intent.action = Action.prevParagraph |
|
|
|
context.startService(intent) |
|
|
|
context.startService(intent) |
|
|
|
} |
|
|
|
} |
|
|
@ -61,7 +61,7 @@ object ReadAloud { |
|
|
|
|
|
|
|
|
|
|
|
fun nextParagraph(context: Context) { |
|
|
|
fun nextParagraph(context: Context) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
val intent = Intent(context, TTSReadAloudService::class.java) |
|
|
|
val intent = Intent(context, aloudClass) |
|
|
|
intent.action = Action.nextParagraph |
|
|
|
intent.action = Action.nextParagraph |
|
|
|
context.startService(intent) |
|
|
|
context.startService(intent) |
|
|
|
} |
|
|
|
} |
|
|
@ -69,7 +69,7 @@ object ReadAloud { |
|
|
|
|
|
|
|
|
|
|
|
fun upTtsSpeechRate(context: Context) { |
|
|
|
fun upTtsSpeechRate(context: Context) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
val intent = Intent(context, TTSReadAloudService::class.java) |
|
|
|
val intent = Intent(context, aloudClass) |
|
|
|
intent.action = Action.upTtsSpeechRate |
|
|
|
intent.action = Action.upTtsSpeechRate |
|
|
|
context.startService(intent) |
|
|
|
context.startService(intent) |
|
|
|
} |
|
|
|
} |
|
|
@ -77,7 +77,7 @@ object ReadAloud { |
|
|
|
|
|
|
|
|
|
|
|
fun setTimer(context: Context, minute: Int) { |
|
|
|
fun setTimer(context: Context, minute: Int) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
val intent = Intent(context, TTSReadAloudService::class.java) |
|
|
|
val intent = Intent(context, aloudClass) |
|
|
|
intent.action = Action.setTimer |
|
|
|
intent.action = Action.setTimer |
|
|
|
intent.putExtra("minute", minute) |
|
|
|
intent.putExtra("minute", minute) |
|
|
|
context.startService(intent) |
|
|
|
context.startService(intent) |
|
|
|