This commit is contained in:
cogwheel0
2025-09-21 20:18:21 +05:30
parent c05644f731
commit 37e5633c5c
2 changed files with 323 additions and 9 deletions

View File

@@ -120,6 +120,16 @@ class TextToSpeechController extends StateNotifier<TextToSpeechState> {
return;
}
final isCurrentlyActive =
state.activeMessageId == messageId &&
state.status != TtsPlaybackStatus.idle &&
state.status != TtsPlaybackStatus.error;
if (isCurrentlyActive) {
await stop();
return;
}
final available = await _ensureInitialized();
if (!available) {
if (!mounted) {
@@ -133,15 +143,6 @@ class TextToSpeechController extends StateNotifier<TextToSpeechState> {
return;
}
final isCurrentlyActive =
state.activeMessageId == messageId &&
state.status != TtsPlaybackStatus.idle;
if (isCurrentlyActive) {
await stop();
return;
}
state = state.copyWith(
status: TtsPlaybackStatus.loading,
activeMessageId: messageId,