From b0c7aa402b048da0e69687ed3ed80dbb9bd5efc0 Mon Sep 17 00:00:00 2001 From: zevav Date: Sun, 4 Oct 2020 16:31:20 +0200 Subject: [PATCH] silly bugy --- modulearn/TODO.md | 4 ++++ modulearn/src/App.svelte | 1 + modulearn/src/Module.svelte | 2 +- modulearn/src/YouTube.svelte | 4 ++-- modulearn/src/utils.js | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modulearn/TODO.md b/modulearn/TODO.md index 15aed48..ef9df0d 100644 --- a/modulearn/TODO.md +++ b/modulearn/TODO.md @@ -17,3 +17,7 @@ - [x] either don't allow going before the first module, or fix it so that the first module isn't highlighted when watching the pre-module content (first solution is easier) - [x] add "flat" drop shadow to progress bar and modules - [ ] add a diagonally oriented aqua triangle at the upper right, as the logo +- [ ] bug: when the newly seleted module is from a different YouTube UID, it doesn't autoplay and it + doesn't advance +- [ ] bug: when you go backwards on the YouTube timeline, it doesn't update the selected module + (forwards is fine) diff --git a/modulearn/src/App.svelte b/modulearn/src/App.svelte index f53c298..a4d0610 100644 --- a/modulearn/src/App.svelte +++ b/modulearn/src/App.svelte @@ -14,6 +14,7 @@ const positionUpdater = () => { interval = setInterval(() => { const pos = video.position() + if (pos == null) return const newModule = getModule(pos, $currentModule) position.update(() => pos) if ((newModule && !$currentModule) || (newModule && $currentModule && newModule.id !== diff --git a/modulearn/src/Module.svelte b/modulearn/src/Module.svelte index fe79f0b..be3da6b 100644 --- a/modulearn/src/Module.svelte +++ b/modulearn/src/Module.svelte @@ -9,8 +9,8 @@ const getProgress = pos => (pos - module.start) / module.duration * 100 let selected; let progress; let klass; let progressBar - $: selected = $currentModule && $currentModule.id === module.id + $: if (selected) { progress = getProgress($position) klass = "current" diff --git a/modulearn/src/YouTube.svelte b/modulearn/src/YouTube.svelte index 6dff10d..1a80b10 100644 --- a/modulearn/src/YouTube.svelte +++ b/modulearn/src/YouTube.svelte @@ -62,9 +62,9 @@ return false; } - export function position() { return player.getCurrentTime() } + export function position() { if (player.getCurrentTime) return player.getCurrentTime() } export function play() { player.playVideo() } - export function jumpTo(seconds) { player.seekTo(seconds) } + export function jumpTo(seconds) { if (player.seekTo) player.seekTo(seconds) } export function pause() { player.pauseVideo() } export function paused() { return [5, 2, -1].includes(player.getPlayerState()) } export function buffering() { return player.getPlayerState() === 3 } diff --git a/modulearn/src/utils.js b/modulearn/src/utils.js index d6bfc84..f324cef 100644 --- a/modulearn/src/utils.js +++ b/modulearn/src/utils.js @@ -1,6 +1,7 @@ import { modules } from './data' export const getModule = (position, currentModule) => { + if (!currentModule) return modules[0] if (position < currentModule.end) { return currentModule }