diff --git a/src/Controls/Sync.astro b/src/Controls/Sync.astro index 79e93db..023f48e 100644 --- a/src/Controls/Sync.astro +++ b/src/Controls/Sync.astro @@ -27,16 +27,16 @@ */ // https://gist.github.com/michancio/59b9f3dc54b3ff4f6a84 // Find elements -var SyncVideo = document.querySelector(".main-video"); -var SyncAudio = document.querySelector(".main-audio"); +var SyncVideo = document.querySelector(".main-video") +var SyncAudio = document.querySelector(".main-audio") // Object for synchronization of multiple media/sources if (typeof window.MediaController === "function") { - var controller = new MediaController(); - SyncVideo.controller = controller; - SyncAudio.controller = controller; + var controller = new MediaController() + SyncVideo.controller = controller + SyncAudio.controller = controller } else { - controller = null; + controller = null } // Run SyncAudio and SyncVideo simultaneously @@ -44,49 +44,49 @@ SyncVideo.addEventListener( "play", function () { if (!controller && SyncAudio.paused) { - SyncAudio.play(); + SyncAudio.play() } }, false, -); +) // Pause/Play and Buffering SyncVideo.addEventListener("waiting", () => { // If SyncVideo is buffering - SyncAudio.pause(); -}); + SyncAudio.pause() +}) SyncVideo.addEventListener("playing", () => { // If SyncVideo is done buffering - SyncAudio.play(); - SyncTimestamp(); -}); + SyncAudio.play() + SyncTimestamp() +}) SyncVideo.addEventListener( "pause", function () { if (!controller && !SyncAudio.paused) { - SyncAudio.pause(); + SyncAudio.pause() } }, false, -); +) // When Media Ends SyncVideo.addEventListener( "ended", function () { if (controller) { - controller.pause(); + controller.pause() } else { - SyncVideo.pause(); - SyncAudio.pause(); + SyncVideo.pause() + SyncAudio.pause() } }, false, -); +) // Seekbar function SyncTimestamp() { - SyncAudio.currentTime = SyncVideo.currentTime; + SyncAudio.currentTime = SyncVideo.currentTime } \ No newline at end of file