From 5936240342cf85423e0acb62976973109cc8324b Mon Sep 17 00:00:00 2001 From: Celestora Date: Tue, 22 Mar 2022 15:44:26 +0200 Subject: [PATCH] Add audio embed thing --- Web/Models/Entities/Audio.php | 25 +++-- Web/Presenters/templates/Audio/Embed.xml | 94 ++++++++++++++++++ Web/static/css/style.css | 118 +++++++++++------------ Web/static/img/pause.jpg | Bin 0 -> 948 bytes Web/static/img/play.jpg | Bin 0 -> 994 bytes Web/static/js/package.json | 1 + Web/static/js/yarn.lock | 63 ++++++++++++ 7 files changed, 231 insertions(+), 70 deletions(-) create mode 100644 Web/Presenters/templates/Audio/Embed.xml create mode 100644 Web/static/img/pause.jpg create mode 100644 Web/static/img/play.jpg diff --git a/Web/Models/Entities/Audio.php b/Web/Models/Entities/Audio.php index 8bd9ccf6..db87c6f3 100644 --- a/Web/Models/Entities/Audio.php +++ b/Web/Models/Entities/Audio.php @@ -69,7 +69,7 @@ class Audio extends Media $this->stateChanges("key", $key); $this->stateChanges("token", $tok); $this->stateChanges("segment_size", $ss); - $this->stateChanges("length", $ss); + $this->stateChanges("length", $duration); try { $args = [ @@ -128,6 +128,19 @@ class Audio extends Media return $this->getRecord()->length; } + function getFormattedLength(): string + { + $len = $this->getLength(); + $mins = floor($len / 60); + $secs = $len - ($mins * 60); + + return ( + str_pad((string) $mins, 2, "0", STR_PAD_LEFT) + . ":" . + str_pad((string) $secs, 2, "0", STR_PAD_LEFT) + ); + } + function getSegmentSize(): float { return $this->getRecord()->segment_size; @@ -162,17 +175,17 @@ class Audio extends Media function isExplicit(): bool { - return $this->getRecord()->explicit; + return (bool) $this->getRecord()->explicit; } function isWithdrawn(): bool { - return $this->getRecord()->withdrawn; + return (bool) $this->getRecord()->withdrawn; } function isUnlisted(): bool { - return $this->getRecord()->unlisted; + return (bool) $this->getRecord()->unlisted; } # NOTICE may flush model to DB if it was just processed @@ -187,8 +200,8 @@ class Audio extends Media try { $fragments = str_replace(".mpd", "_fragments", $this->getFileName()); - $original = "original_" . bin2hex($this->getRecord()->token) . "mp3"; - if (file_exists("$fragments/$original")) { + $original = "original_" . bin2hex($this->getRecord()->token) . ".mp3"; + if(file_exists("$fragments/$original")) { # Original gets uploaded after fragments $this->stateChanges("processed", 0x01); diff --git a/Web/Presenters/templates/Audio/Embed.xml b/Web/Presenters/templates/Audio/Embed.xml new file mode 100644 index 00000000..7f9e8714 --- /dev/null +++ b/Web/Presenters/templates/Audio/Embed.xml @@ -0,0 +1,94 @@ + + + + + + {$audio->getName()} + + {css "css/style.css"} + + +