fix: ensure MP3 controls show after loading MP3/JSON pair
This commit is contained in:
parent
babf28e77c
commit
c22a20b2c8
@ -520,20 +520,22 @@ class MainViewModel(
|
||||
}
|
||||
|
||||
private fun handlePlayText() {
|
||||
Timber.d("handlePlayText called.")
|
||||
viewModelScope.launch {
|
||||
// Decide which text to speak: prioritize loaded doc, then user input
|
||||
val textToSpeak = when {
|
||||
currentPageText.value.isNotEmpty() -> currentPageText.value
|
||||
fullDocumentText.value.isNotEmpty() -> fullDocumentText.value
|
||||
userInputText.value.isNotEmpty() -> userInputText.value
|
||||
else -> {
|
||||
Timber.w("PlayText action called but no text available (document or input).")
|
||||
return@launch
|
||||
}
|
||||
// --- ADD CHECK: Do not start TTS if an MP3 is loaded ---
|
||||
if (_currentMp3Uri.value != null) {
|
||||
Timber.w("handlePlayText: MP3 URI is loaded ($_currentMp3Uri.value). Skipping TTS playback.")
|
||||
return@launch
|
||||
}
|
||||
// --- END CHECK ---
|
||||
|
||||
Timber.d("handlePlayText: Speaking text starting with: '${textToSpeak.take(50)}...'")
|
||||
speakTextUseCase(textToSpeak)
|
||||
val textToSpeak = getCurrentDocumentStateUseCase.currentPageText.value
|
||||
if (!textToSpeak.isNullOrBlank()) {
|
||||
Timber.d("Speaking current page text: '${textToSpeak.take(50)}...'")
|
||||
speakTextUseCase(textToSpeak)
|
||||
} else {
|
||||
Timber.w("PlayText action called but no text available (document or input).")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1082,6 +1084,11 @@ class MainViewModel(
|
||||
processDocumentUseCase.processText(reconstructedText)
|
||||
// State should now be updated in the repository, triggering UI updates
|
||||
_processingStatus.value = PdfProcessingStatus.READY_TO_PLAY // Use the READY state
|
||||
|
||||
// *** ADDED: Set the current MP3 URI state ***
|
||||
_currentMp3Uri.value = mp3Uri
|
||||
// *** END ADDED ***
|
||||
|
||||
Timber.d("Document state updated via use case. Attempting to play MP3: $mp3Uri")
|
||||
playMp3UseCase(mp3Uri) // Play after state is set
|
||||
} catch (processError: Exception) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user