Skip to content

Commit

Permalink
Don't restart utterance in TTS when submitting the same preferences a…
Browse files Browse the repository at this point in the history
…gain (readium#530)
  • Loading branch information
qnga authored Jun 7, 2024
1 parent 852d1c9 commit acac9b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ public class TtsNavigator<S : TtsEngine.Settings, P : TtsEngine.Preferences<P>,

override fun submitPreferences(preferences: P) {
player.submitPreferences(preferences)
player.restartUtterance()
}

private fun navigatorPlayback(playback: TtsPlayer.Playback, utterance: TtsPlayer.Utterance) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ internal class TtsPlayer<S : TtsEngine.Settings, P : TtsEngine.Preferences<P>,
initialPreferences

init {
submitPreferences(initialPreferences)
submitPreferencesForSure(initialPreferences)
}

fun play() {
Expand Down Expand Up @@ -560,6 +560,15 @@ internal class TtsPlayer<S : TtsEngine.Settings, P : TtsEngine.Preferences<P>,
}

override fun submitPreferences(preferences: P) {
if (preferences == lastPreferences) {
return
}

submitPreferencesForSure(preferences)
restartUtterance()
}

private fun submitPreferencesForSure(preferences: P) {
lastPreferences = preferences
engineFacade.submitPreferences(preferences)
contentIterator.language = engineFacade.settings.value.language
Expand Down

0 comments on commit acac9b4

Please sign in to comment.