diff --git a/src/Player.svelte b/src/Player.svelte index f636549..dd748bc 100644 --- a/src/Player.svelte +++ b/src/Player.svelte @@ -30,6 +30,14 @@ } } + function synchronize(what) { + if (what == "audio") { + audioPlayer.seekTo(videoPlayer.getCurrentTime(), true); + } else { + videoPlayer.seekTo(audioPlayer.getCurrentTime(), true); + } + } + async function init() { const currentResult = await fetch("grid.php"); if (!currentResult.ok) { @@ -51,6 +59,12 @@ onReady: () => { videoReady = true; }, + onStateChange: (ev) => { + // Paused + if (ev.data == 2) { + synchronize("audio"); + } + }, }, }); @@ -65,6 +79,12 @@ onReady: () => { audioReady = true; }, + onStateChange: (ev) => { + // Paused + if (ev.data == 2) { + synchronize("video"); + } + }, }, }); }