From 520587cc56d8d0d2d2858e4f351f07472a74fd5d Mon Sep 17 00:00:00 2001
From: mrilyew <99399973+mrilyew@users.noreply.github.com>
Date: Fri, 14 Mar 2025 19:28:55 +0300
Subject: [PATCH] feat(player): some tweaks
---
VKAPI/Handlers/Audio.php | 6 +--
Web/Presenters/templates/Audio/List.xml | 18 ++++++-
Web/Presenters/templates/Audio/bigplayer.xml | 4 ++
Web/static/css/audios.css | 31 +++++++++++-
Web/static/js/al_music.js | 50 +++++++++++++++++---
locales/en.strings | 9 +++-
locales/ru.strings | 9 +++-
7 files changed, 114 insertions(+), 13 deletions(-)
diff --git a/VKAPI/Handlers/Audio.php b/VKAPI/Handlers/Audio.php
index b84475a4..df9cf935 100644
--- a/VKAPI/Handlers/Audio.php
+++ b/VKAPI/Handlers/Audio.php
@@ -18,7 +18,7 @@ final class Audio extends VKAPIRequestHandler
if (!$audio) {
$this->fail(0o404, "Audio not found");
} elseif (!$audio->canBeViewedBy($this->getUser())) {
- $this->fail(201, "Access denied to audio(" . $audio->getPrettyId() . ")");
+ $this->fail(201, "Access denied to audio(" . $audio->getId() . ")");
}
# рофлан ебало
@@ -201,7 +201,7 @@ final class Audio extends VKAPIRequestHandler
$this->fail(15, "Access denied");
}
- if ($uploaded_only) {
+ if ($uploaded_only && $owner_id == $this->getUser()->getRealId()) {
return DatabaseConnection::i()->getContext()->table("audios")
->where([
"deleted" => false,
@@ -283,7 +283,7 @@ final class Audio extends VKAPIRequestHandler
}
$dbCtx = DatabaseConnection::i()->getContext();
- if ($uploaded_only == 1) {
+ if ($uploaded_only == 1 && $owner_id == $this->getUser()->getRealId()) {
if ($owner_id <= 0) {
$this->fail(8, "uploaded_only can only be used with owner_id > 0");
}
diff --git a/Web/Presenters/templates/Audio/List.xml b/Web/Presenters/templates/Audio/List.xml
index 1483ce95..606022fe 100644
--- a/Web/Presenters/templates/Audio/List.xml
+++ b/Web/Presenters/templates/Audio/List.xml
@@ -58,7 +58,7 @@
{block content}
{* ref: https://archive.li/P32em *}
- {include "bigplayer.xml"}
+ {include "bigplayer.xml", buttonsShow_summary => $audiosCount > 10}
+
+
+ {tr("is_x_audio", $audiosCount)}
+
+
+ {include "../components/paginator.xml", conf => (object) [
+ "page" => $page,
+ "count" => $audiosCount,
+ "amount" => sizeof($audios),
+ "perPage" => $perPage ?? OPENVK_DEFAULT_PER_PAGE,
+ "atTop" => true,
+ "space" => 6,
+ "tidy" => true,
+ ]}
+
+
diff --git a/Web/Presenters/templates/Audio/bigplayer.xml b/Web/Presenters/templates/Audio/bigplayer.xml
index fcda029a..d30b7a07 100644
--- a/Web/Presenters/templates/Audio/bigplayer.xml
+++ b/Web/Presenters/templates/Audio/bigplayer.xml
@@ -52,5 +52,9 @@
+
+
diff --git a/Web/static/css/audios.css b/Web/static/css/audios.css
index cd49b006..69e194b9 100644
--- a/Web/static/css/audios.css
+++ b/Web/static/css/audios.css
@@ -52,6 +52,35 @@
height: 46px;
}
+/* кто прочитал тому не завидую */
+.bigPlayer .bigPlayerWrapper .absoluteButtons {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+}
+
+.bigPlayer .bigPlayerWrapper .absoluteButtons > div {
+ width: 8px;
+ height: 8px;
+ font-size: 9px;
+
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: #ebebeb;
+ border: 1px solid #c3c3c3;
+ border-bottom: unset;
+ border-right: unset;
+ color: #c3c3c3;
+ cursor: pointer;
+ user-select: none;
+}
+
+.bigPlayer .bigPlayerWrapper .absoluteButtons > div:active {
+ background: #c3c3c3;
+ color: #ebebeb;
+}
+
/* Play button and arrows */
.bigPlayer .playButtons {
display: flex;
@@ -313,7 +342,7 @@
opacity: 0.8;
}
-.audioEmbed.processed {
+.audioEmbed.processed .playerButton {
filter: opacity(0.6);
}
diff --git a/Web/static/js/al_music.js b/Web/static/js/al_music.js
index 9e166d58..fc35174e 100644
--- a/Web/static/js/al_music.js
+++ b/Web/static/js/al_music.js
@@ -54,6 +54,9 @@ window.player = new class {
current_track_id = 0
tracks = []
+ // time type:
+ // 0 - shows remaining time before end
+ // 1 - shows full track time
get timeType() {
return localStorage.getItem('audio.timeType') ?? 0
}
@@ -62,6 +65,7 @@ window.player = new class {
localStorage.setItem('audio.timeType', value)
}
+ //