From 1b1a371e9e77c782c3ad30b8d46e452bae201e2b Mon Sep 17 00:00:00 2001 From: Elliott-Liu <16389800+Elliott-Liu@users.noreply.github.com> Date: Tue, 7 Feb 2023 19:44:00 +0000 Subject: [PATCH 1/5] Rename existing command in line with function --- main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index b4b2a11..331686e 100644 --- a/main.ts +++ b/main.ts @@ -122,8 +122,8 @@ export default class TimestampPlugin extends Plugin { //Command that play/pauses the video this.addCommand({ - id: 'pause-player', - name: 'Pause player', + id: 'toggle-play-pause-video', + name: 'Toggle play/pause video', editorCallback: (editor: Editor, view: MarkdownView) => { this.setPlaying(!this.player.props.playing) } From 681d68ee19567ba26d8dec4f30e9ead1502da8e2 Mon Sep 17 00:00:00 2001 From: Elliott-Liu <16389800+Elliott-Liu@users.noreply.github.com> Date: Tue, 7 Feb 2023 19:52:16 +0000 Subject: [PATCH 2/5] Existing playback commands work in all edit modes `editorCallback` restricts playback commands to MarkdownView only. This has been replaced with `callback` to enable playback control in any editing mode Obsidian. --- main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index 331686e..f62989d 100644 --- a/main.ts +++ b/main.ts @@ -124,7 +124,7 @@ export default class TimestampPlugin extends Plugin { this.addCommand({ id: 'toggle-play-pause-video', name: 'Toggle play/pause video', - editorCallback: (editor: Editor, view: MarkdownView) => { + callback: () => { this.setPlaying(!this.player.props.playing) } }); @@ -133,7 +133,7 @@ export default class TimestampPlugin extends Plugin { this.addCommand({ id: 'seek-forward', name: 'Seek Forward', - editorCallback: (editor: Editor, view: MarkdownView) => { + callback: () => { if (this.player) this.player.seekTo(this.player.getCurrentTime() + parseInt(this.settings.forwardSeek)); } }); @@ -142,7 +142,7 @@ export default class TimestampPlugin extends Plugin { this.addCommand({ id: 'seek-backward', name: 'Seek Backward', - editorCallback: (editor: Editor, view: MarkdownView) => { + callback: () => { if (this.player) this.player.seekTo(this.player.getCurrentTime() - parseInt(this.settings.backwardsSeek)); } }); From 9522c2ea738e5b3286b67a11699b6d9ad4e614ff Mon Sep 17 00:00:00 2001 From: Elliott-Liu <16389800+Elliott-Liu@users.noreply.github.com> Date: Tue, 7 Feb 2023 19:52:51 +0000 Subject: [PATCH 3/5] Add exclusive "Play video" command --- main.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.ts b/main.ts index f62989d..850ab0d 100644 --- a/main.ts +++ b/main.ts @@ -129,6 +129,15 @@ export default class TimestampPlugin extends Plugin { } }); + //Command that plays the video + this.addCommand({ + id: 'play-video', + name: 'Play video', + callback: () => { + this.setPlaying(true) + } + }); + // Seek forward by set amount of seconds this.addCommand({ id: 'seek-forward', From 1763bd166c5a1a876672d8b3dd6405176ceb42e7 Mon Sep 17 00:00:00 2001 From: Elliott-Liu <16389800+Elliott-Liu@users.noreply.github.com> Date: Tue, 7 Feb 2023 19:53:04 +0000 Subject: [PATCH 4/5] Add exclusive "Pause video" command --- main.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.ts b/main.ts index 850ab0d..126de03 100644 --- a/main.ts +++ b/main.ts @@ -138,6 +138,15 @@ export default class TimestampPlugin extends Plugin { } }); + //Command that pauses the video + this.addCommand({ + id: 'pause-video', + name: 'Pause video', + callback: () => { + this.setPlaying(false) + } + }); + // Seek forward by set amount of seconds this.addCommand({ id: 'seek-forward', From ac3ef42bf02b8e8c075b9f11c0610f5df5468bfe Mon Sep 17 00:00:00 2001 From: Elliott-Liu <16389800+Elliott-Liu@users.noreply.github.com> Date: Tue, 7 Feb 2023 19:55:11 +0000 Subject: [PATCH 5/5] Make command name capitalisation consistent --- main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index 126de03..eb84dfb 100644 --- a/main.ts +++ b/main.ts @@ -150,7 +150,7 @@ export default class TimestampPlugin extends Plugin { // Seek forward by set amount of seconds this.addCommand({ id: 'seek-forward', - name: 'Seek Forward', + name: 'Seek forward', callback: () => { if (this.player) this.player.seekTo(this.player.getCurrentTime() + parseInt(this.settings.forwardSeek)); } @@ -159,7 +159,7 @@ export default class TimestampPlugin extends Plugin { // Seek backwards by set amount of seconds this.addCommand({ id: 'seek-backward', - name: 'Seek Backward', + name: 'Seek backward', callback: () => { if (this.player) this.player.seekTo(this.player.getCurrentTime() - parseInt(this.settings.backwardsSeek)); }