From b609f09316936cede1b864a8505d1004412c9453 Mon Sep 17 00:00:00 2001 From: monochromer Date: Fri, 15 Sep 2023 13:32:53 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=B8=D1=82=20=D0=B8?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8E=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=B0=D1=81=D1=82?= =?UTF-8?q?=D0=B5=20(#332)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/modules/podcast.js | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/scripts/modules/podcast.js b/src/scripts/modules/podcast.js index f548441dc..7b7a76cbf 100644 --- a/src/scripts/modules/podcast.js +++ b/src/scripts/modules/podcast.js @@ -33,6 +33,18 @@ function setTime(time) { player.currentTime = time; } +/** Перемотка аудио назад на `seconds` секунд + * @param seconds количество секунд + */ +function rewindAudio(seconds) { + if (player.duration && !isNaN(player.duration)) { + const currentTime = player.currentTime; + const targetTime = currentTime + seconds; + + player.currentTime = targetTime; + } +} + function handlePassedTimecode() { const passed = matchTimecode(document.URL); @@ -61,24 +73,13 @@ if (player) { handlePassedTimecode(); } initAnchor(); -} - -backButton.addEventListener('click', () => { - rewindAudio(-10); -}); -forwardButton.addEventListener('click', () => { - rewindAudio(10); -}); - -/** Перемотка аудио назад на `seconds` секунд - * @param seconds количество секунд - */ -function rewindAudio(seconds) { - if (player.duration && !isNaN(player.duration)) { - const currentTime = player.currentTime; - const targetTime = currentTime + seconds; + backButton.addEventListener('click', () => { + rewindAudio(-10); + }); - player.currentTime = targetTime; - } + forwardButton.addEventListener('click', () => { + rewindAudio(10); + }); } +