diff --git a/docs/docs/commands.md b/docs/docs/commands.md index 865f04d..03345ed 100644 --- a/docs/docs/commands.md +++ b/docs/docs/commands.md @@ -11,6 +11,9 @@ This will start playback if the current episode is paused. ## Stop Podcast This will stop playback if the current episode is playing. +## Toggle playback +This will toggle playback between playing and paused. + ## Skip Backward This will skip the current episode back by the amount of seconds specified in the settings. diff --git a/src/API/API.ts b/src/API/API.ts index b049ef3..07019fb 100644 --- a/src/API/API.ts +++ b/src/API/API.ts @@ -77,6 +77,10 @@ export class API implements IAPI { isPaused.update((_) => true); } + togglePlayback(): void { + isPaused.update((isPaused) => !isPaused); + } + skipBackward(): void { const skipBackLen = get(plugin).settings.skipBackwardLength; this.currentTime -= skipBackLen; diff --git a/src/API/IAPI.ts b/src/API/IAPI.ts index c7970f4..a0bd299 100644 --- a/src/API/IAPI.ts +++ b/src/API/IAPI.ts @@ -10,6 +10,7 @@ export interface IAPI { start(): void; stop(): void; + togglePlayback(): void; skipBackward(): void; skipForward(): void; diff --git a/src/main.ts b/src/main.ts index 7a913a5..efdd108 100644 --- a/src/main.ts +++ b/src/main.ts @@ -313,6 +313,18 @@ export default class PodNotes extends Plugin implements IPodNotes { }, }); + this.addCommand({ + id: 'podnotes-toggle-playback', + name: 'Toggle playback', + checkCallback: (checking) => { + if (checking) { + return !!this.api.podcast; + } + + this.api.togglePlayback(); + } + }) + this.addSettingTab(new PodNotesSettingsTab(this.app, this)); this.registerView(VIEW_TYPE, (leaf: WorkspaceLeaf) => {