Skip to content

Commit

Permalink
feat: add command to toggle playback
Browse files Browse the repository at this point in the history
if paused, play. if playing, pause.
  • Loading branch information
chhoumann committed Feb 9, 2023
1 parent 84ac2cf commit 388482a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions src/API/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/API/IAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface IAPI {

start(): void;
stop(): void;
togglePlayback(): void;

skipBackward(): void;
skipForward(): void;
Expand Down
12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

1 comment on commit 388482a

@vercel
Copy link

@vercel vercel bot commented on 388482a Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.