Skip to content

Commit

Permalink
TTS: stop speaking when closing
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfactotum committed Sep 28, 2023
1 parent 641a20c commit 01c6519
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/book-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ export const BookViewer = GObject.registerClass({
exportAnnotations(this.get_root(), this.#data.storage.export())
}
vfunc_unroot() {
this._navbar.tts_box.kill()
this._view.viewSettings.unbindSettings()
this._view.fontSettings.unbindSettings()
utils.disconnectWith(this, this.#data.annotations)
Expand Down
5 changes: 5 additions & 0 deletions src/tts.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const TTSBox = GObject.registerClass({
else state = message
}
if (state === 'END' && await this.emit('next-section')) this.start()
else this.state = 'stopped'
}
play() {
if (this.#state !== 'playing') this.start()
Expand Down Expand Up @@ -97,4 +98,8 @@ export const TTSBox = GObject.registerClass({
// TODO: display error
console.error(e)
}
kill() {
this.emit = () => {}
if (this.state === 'playing') ssip.stop().catch(e => console.error(e))
}
})

0 comments on commit 01c6519

Please sign in to comment.