From da82c84730f1c5240ae928dbc4ac45a1bf7cf0c2 Mon Sep 17 00:00:00 2001 From: veselcraft Date: Tue, 26 Nov 2024 03:32:40 +0300 Subject: [PATCH] feat(music): syncronized lyrics by lrc file format !!!DRAFT!!! Co-authored-by: Mikhail Serebryakov <126566943+synzr@users.noreply.github.com> --- Web/Models/Entities/Audio.php | 5 + Web/Presenters/AudioPresenter.php | 11 ++ Web/Presenters/templates/Audio/bigplayer.xml | 2 + Web/Presenters/templates/Audio/player.xml | 2 +- Web/routes.yml | 2 + Web/static/css/audios.css | 53 ++++++- Web/static/img/audios_controls.png | Bin 4287 -> 5489 bytes Web/static/js/al_music.js | 141 ++++++++++++++++++- locales/en.strings | 2 + locales/ru.strings | 2 + locales/uk.strings | 2 + 11 files changed, 214 insertions(+), 8 deletions(-) mode change 100644 => 100755 Web/static/img/audios_controls.png diff --git a/Web/Models/Entities/Audio.php b/Web/Models/Entities/Audio.php index 3b998f32..de7114b4 100644 --- a/Web/Models/Entities/Audio.php +++ b/Web/Models/Entities/Audio.php @@ -167,6 +167,11 @@ class Audio extends Media return !is_null($this->getRecord()->lyrics) ? htmlspecialchars($this->getRecord()->lyrics, ENT_DISALLOWED | ENT_XHTML) : NULL; } + function getLRC(): ?string + { + return !is_null($this->getRecord()->lrc) ? htmlspecialchars($this->getRecord()->lrc, ENT_DISALLOWED | ENT_XHTML) : NULL; + } + function getLength(): int { return $this->getRecord()->length; diff --git a/Web/Presenters/AudioPresenter.php b/Web/Presenters/AudioPresenter.php index ae38d1d0..d06c9c0a 100644 --- a/Web/Presenters/AudioPresenter.php +++ b/Web/Presenters/AudioPresenter.php @@ -802,4 +802,15 @@ final class AudioPresenter extends OpenVKPresenter $this->returnJson($resultArr); } + + function renderLRC(int $id) { + $audio = (new Audios)->get($id); + header("Content-Type: application/octet-stream"); + + if ($audio->isAvailable()) { + exit($audio->getLRC()); + } else { + exit(""); + } + } } diff --git a/Web/Presenters/templates/Audio/bigplayer.xml b/Web/Presenters/templates/Audio/bigplayer.xml index 6ae6326d..c400839d 100644 --- a/Web/Presenters/templates/Audio/bigplayer.xml +++ b/Web/Presenters/templates/Audio/bigplayer.xml @@ -48,9 +48,11 @@
+
+
diff --git a/Web/Presenters/templates/Audio/player.xml b/Web/Presenters/templates/Audio/player.xml index 24fe4723..031b3f0c 100644 --- a/Web/Presenters/templates/Audio/player.xml +++ b/Web/Presenters/templates/Audio/player.xml @@ -2,7 +2,7 @@ {php $isWithdrawn = $audio->isWithdrawn()} {php $isAvailable = $audio->isAvailable()} {php $editable = isset($thisUser) && $audio->canBeModifiedBy($thisUser)} -
+
getLRC()) }data-lrc="/audio{$audio->getId()}/lrc"{/if}>