Skip to content

Commit

Permalink
Merge pull request #29 from 1C0D/master
Browse files Browse the repository at this point in the history
Start pause resume playback command
  • Loading branch information
joethei authored Jul 14, 2023
2 parents 926d960 + c314cd2 commit a712e86
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-tts",
"name": "Text to Speech",
"version": "0.5.1",
"version": "0.5.2",
"minAppVersion": "0.12.0",
"description": "Text to speech for Obsidian. Hear your notes.",
"author": "Johannes Theiner",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-tts",
"version": "0.5.1",
"version": "0.5.2",
"description": "Text to speech for Obsidian. Hear your notes.",
"main": "main.js",
"scripts": {
Expand Down
22 changes: 22 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ export default class TTSPlugin extends Plugin {
}
});

this.addCommand({
id: 'start-pause-resume-tts-playback',
name: 'Start/Pause/Resume playback',
checkCallback: (checking: boolean) => {
const markdownView = this.app.workspace.getActiveViewOfType(MarkdownView);
if (!checking) {
if (markdownView) {
if (this.ttsService.isSpeaking() && !this.ttsService.isPaused()) {
this.ttsService.pause();
}
else if (this.ttsService.isPaused()) {
this.ttsService.resume();
}
else {
this.ttsService.play(markdownView);
}
}
}
return !!markdownView
}
});

//clear statusbar text if not speaking
this.registerInterval(window.setInterval(() => {
if (!this.ttsService.isSpeaking()) {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"0.3.5": "0.12.0",
"0.4.0": "0.12.0",
"0.5.0": "0.12.0",
"0.5.1": "0.12.0"
"0.5.1": "0.12.0",
"0.5.2": "0.12.0"
}

0 comments on commit a712e86

Please sign in to comment.