mirror of
https://github.com/openvk/openvk
synced 2025-04-19 14:43:01 +03:00
feat(player): some tweaks
This commit is contained in:
parent
b92bf7f41a
commit
520587cc56
7 changed files with 114 additions and 13 deletions
|
@ -18,7 +18,7 @@ final class Audio extends VKAPIRequestHandler
|
||||||
if (!$audio) {
|
if (!$audio) {
|
||||||
$this->fail(0o404, "Audio not found");
|
$this->fail(0o404, "Audio not found");
|
||||||
} elseif (!$audio->canBeViewedBy($this->getUser())) {
|
} 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");
|
$this->fail(15, "Access denied");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($uploaded_only) {
|
if ($uploaded_only && $owner_id == $this->getUser()->getRealId()) {
|
||||||
return DatabaseConnection::i()->getContext()->table("audios")
|
return DatabaseConnection::i()->getContext()->table("audios")
|
||||||
->where([
|
->where([
|
||||||
"deleted" => false,
|
"deleted" => false,
|
||||||
|
@ -283,7 +283,7 @@ final class Audio extends VKAPIRequestHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbCtx = DatabaseConnection::i()->getContext();
|
$dbCtx = DatabaseConnection::i()->getContext();
|
||||||
if ($uploaded_only == 1) {
|
if ($uploaded_only == 1 && $owner_id == $this->getUser()->getRealId()) {
|
||||||
if ($owner_id <= 0) {
|
if ($owner_id <= 0) {
|
||||||
$this->fail(8, "uploaded_only can only be used with owner_id > 0");
|
$this->fail(8, "uploaded_only can only be used with owner_id > 0");
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
{block content}
|
{block content}
|
||||||
{* ref: https://archive.li/P32em *}
|
{* ref: https://archive.li/P32em *}
|
||||||
|
|
||||||
{include "bigplayer.xml"}
|
{include "bigplayer.xml", buttonsShow_summary => $audiosCount > 10}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.__current_page_audio_context = null
|
window.__current_page_audio_context = null
|
||||||
|
@ -77,6 +77,22 @@
|
||||||
{/if}
|
{/if}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div class='summaryBarHideable summaryBar summaryBarFlex padding' style="margin: 0px -10px;width: 99.5%;display: none;">
|
||||||
|
<div class='summary'>
|
||||||
|
<b>{tr("is_x_audio", $audiosCount)}</b>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{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,
|
||||||
|
]}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="audiosDiv">
|
<div class="audiosDiv">
|
||||||
<div class="audiosContainer audiosSideContainer audiosPaddingContainer" n:if="$mode != 'playlists'">
|
<div class="audiosContainer audiosSideContainer audiosPaddingContainer" n:if="$mode != 'playlists'">
|
||||||
<div n:if="$audiosCount <= 0" style='height: 100%;'>
|
<div n:if="$audiosCount <= 0" style='height: 100%;'>
|
||||||
|
|
|
@ -52,5 +52,9 @@
|
||||||
<div class="shuffleButton musicIcon" data-tip='simple' data-title="{_shuffle_tip}"></div>
|
<div class="shuffleButton musicIcon" data-tip='simple' data-title="{_shuffle_tip}"></div>
|
||||||
<div class="deviceButton musicIcon" data-tip='simple' data-title="{_mute_tip} [M]"></div>
|
<div class="deviceButton musicIcon" data-tip='simple' data-title="{_mute_tip} [M]"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="absoluteButtons">
|
||||||
|
<div n:if="$buttonsShow_summary" id="summarySwitchButton">-</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -52,6 +52,35 @@
|
||||||
height: 46px;
|
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 */
|
/* Play button and arrows */
|
||||||
.bigPlayer .playButtons {
|
.bigPlayer .playButtons {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -313,7 +342,7 @@
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.audioEmbed.processed {
|
.audioEmbed.processed .playerButton {
|
||||||
filter: opacity(0.6);
|
filter: opacity(0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,9 @@ window.player = new class {
|
||||||
current_track_id = 0
|
current_track_id = 0
|
||||||
tracks = []
|
tracks = []
|
||||||
|
|
||||||
|
// time type:
|
||||||
|
// 0 - shows remaining time before end
|
||||||
|
// 1 - shows full track time
|
||||||
get timeType() {
|
get timeType() {
|
||||||
return localStorage.getItem('audio.timeType') ?? 0
|
return localStorage.getItem('audio.timeType') ?? 0
|
||||||
}
|
}
|
||||||
|
@ -62,6 +65,7 @@ window.player = new class {
|
||||||
localStorage.setItem('audio.timeType', value)
|
localStorage.setItem('audio.timeType', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <audio> tag
|
||||||
get audioPlayer() {
|
get audioPlayer() {
|
||||||
return this.__realAudioPlayer
|
return this.__realAudioPlayer
|
||||||
}
|
}
|
||||||
|
@ -322,6 +326,8 @@ window.player = new class {
|
||||||
|
|
||||||
this.__updateFace()
|
this.__updateFace()
|
||||||
u(this.audioPlayer).trigger('volumechange')
|
u(this.audioPlayer).trigger('volumechange')
|
||||||
|
|
||||||
|
document.title = ovk_proc_strtr(escapeHtml(`${window.player.currentTrack.performer} — ${window.player.currentTrack.name}`), 255)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasContext() {
|
hasContext() {
|
||||||
|
@ -377,7 +383,7 @@ window.player = new class {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.setTrack(this.previousTrack.id)
|
await this.setTrack(this.previousTrack.id)
|
||||||
if(!this.currentTrack.available || this.currentTrack.withdrawn) {
|
if(/*!this.currentTrack.available || */this.currentTrack.withdrawn) {
|
||||||
if(!this.previousTrack) {
|
if(!this.previousTrack) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -394,7 +400,7 @@ window.player = new class {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.setTrack(this.nextTrack.id)
|
await this.setTrack(this.nextTrack.id)
|
||||||
if(!this.currentTrack.available || this.currentTrack.withdrawn) {
|
if(/*!this.currentTrack.available || */this.currentTrack.withdrawn) {
|
||||||
if(!this.nextTrack) {
|
if(!this.nextTrack) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -664,6 +670,8 @@ window.player = new class {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the listen counts if you reach half of song
|
||||||
|
// but it doesnt checks on server normally so you can "накрутить" listens
|
||||||
async __countListen() {
|
async __countListen() {
|
||||||
let playlist = 0
|
let playlist = 0
|
||||||
if(!this.listen_coef) {
|
if(!this.listen_coef) {
|
||||||
|
@ -787,6 +795,10 @@ window.player = new class {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleSummary() {
|
||||||
|
$(".summaryBarHideable").slideToggle(300, "linear")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", async () => {
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
|
@ -1163,7 +1175,25 @@ u(document).on("drop", '.audiosContainer', function(e) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
u(document).on("click", "#summarySwitchButton", (e) => {
|
||||||
|
if(u(".summaryBarHideable").nodes[0].style.overflow == "hidden") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(u(e.target).html() == "-") {
|
||||||
|
u(e.target).html("+")
|
||||||
|
} else {
|
||||||
|
u(e.target).html("-")
|
||||||
|
}
|
||||||
|
|
||||||
|
window.player.toggleSummary()
|
||||||
|
})
|
||||||
|
|
||||||
u(document).on('contextmenu', '.bigPlayer, .audioEmbed, #ajax_audio_player', (e) => {
|
u(document).on('contextmenu', '.bigPlayer, .audioEmbed, #ajax_audio_player', (e) => {
|
||||||
|
if(e.shiftKey) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
u('#ctx_menu').remove()
|
u('#ctx_menu').remove()
|
||||||
|
@ -1179,6 +1209,10 @@ u(document).on('contextmenu', '.bigPlayer, .audioEmbed, #ajax_audio_player', (e)
|
||||||
x = e.pageX - rx
|
x = e.pageX - rx
|
||||||
y = e.pageY - ry
|
y = e.pageY - ry
|
||||||
|
|
||||||
|
if((rect.height + rect.top) + 100 > window.innerHeight) {
|
||||||
|
y = ((rect.height + 120) * -1)
|
||||||
|
}
|
||||||
|
|
||||||
const ctx_u = u(`
|
const ctx_u = u(`
|
||||||
<div id='ctx_menu' style='top:${y}px;left:${x}px;' data-type='ctx_type'>
|
<div id='ctx_menu' style='top:${y}px;left:${x}px;' data-type='ctx_type'>
|
||||||
<a id='audio_ctx_copy'>${tr('copy_link_to_audio')}</a>
|
<a id='audio_ctx_copy'>${tr('copy_link_to_audio')}</a>
|
||||||
|
@ -1194,7 +1228,7 @@ u(document).on('contextmenu', '.bigPlayer, .audioEmbed, #ajax_audio_player', (e)
|
||||||
<a id='audio_ctx_add_to_playlist'>${tr('audio_ctx_add_to_playlist')}</a>
|
<a id='audio_ctx_add_to_playlist'>${tr('audio_ctx_add_to_playlist')}</a>
|
||||||
${ctx_type == 'main_player' ? `
|
${ctx_type == 'main_player' ? `
|
||||||
<a id='audio_ctx_clear_context'>${tr('audio_ctx_clear_context')}</a>` : ''}
|
<a id='audio_ctx_clear_context'>${tr('audio_ctx_clear_context')}</a>` : ''}
|
||||||
${ctx_type == 'main_player' ? `<a href='https://github.com/mrilyew' target='_blank'>BigPlayer v1.1 by MrIlyew</a>` : ''}
|
${ctx_type == 'main_player' ? `<a href='https://github.com/mrilyew' target='_blank'>BigPlayer v1.2 by MrIlyew</a>` : ''}
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
u(parent).append(ctx_u)
|
u(parent).append(ctx_u)
|
||||||
|
@ -1948,8 +1982,12 @@ $(document).on("click", ".audioEmbed.processed .playerButton", (e) => {
|
||||||
title: tr('error'),
|
title: tr('error'),
|
||||||
body: tr('audio_embed_processing'),
|
body: tr('audio_embed_processing'),
|
||||||
unique_name: 'processing_notify',
|
unique_name: 'processing_notify',
|
||||||
buttons: [tr('ok')],
|
buttons: [tr("audio_embed_processing_bait"), tr('ok')],
|
||||||
callbacks: [Function.noop]
|
callbacks: [() => {
|
||||||
|
const pl = u(e.target).closest(".audioEmbed")
|
||||||
|
pl.removeClass("processed")
|
||||||
|
pl.find(".playIcon").trigger("click")
|
||||||
|
}, Function.noop]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -928,7 +928,8 @@
|
||||||
"audio_embed_deleted" = "Audio has been deleted";
|
"audio_embed_deleted" = "Audio has been deleted";
|
||||||
"audio_embed_withdrawn" = "The audio has been withdrawn at the request of the copyright holder";
|
"audio_embed_withdrawn" = "The audio has been withdrawn at the request of the copyright holder";
|
||||||
"audio_embed_forbidden" = "The user's privacy settings do not allow this audio to be embedded";
|
"audio_embed_forbidden" = "The user's privacy settings do not allow this audio to be embedded";
|
||||||
"audio_embed_processing" = "Audio is still being processed or has not been processed correctly.";
|
"audio_embed_processing" = "Audio is processing.";
|
||||||
|
"audio_embed_processing_bait" = "Play anyway";
|
||||||
|
|
||||||
"audios_count_zero" = "No audios";
|
"audios_count_zero" = "No audios";
|
||||||
"audios_count_one" = "One audio";
|
"audios_count_one" = "One audio";
|
||||||
|
@ -1038,6 +1039,12 @@
|
||||||
"audio_ctx_play_next" = "Play next";
|
"audio_ctx_play_next" = "Play next";
|
||||||
"audio_ctx_clear_context" = "Clear tracks list";
|
"audio_ctx_clear_context" = "Clear tracks list";
|
||||||
|
|
||||||
|
"is_x_audio_zero" = "No audios";
|
||||||
|
"is_x_audio_one" = "Just one audio.";
|
||||||
|
"is_x_audio_few" = "Just $1 audios.";
|
||||||
|
"is_x_audio_many" = "Just $1 audios.";
|
||||||
|
"is_x_audio_other" = "Just $1 audios.";
|
||||||
|
|
||||||
/* Notifications */
|
/* Notifications */
|
||||||
|
|
||||||
"feedback" = "Feedback";
|
"feedback" = "Feedback";
|
||||||
|
|
|
@ -883,7 +883,8 @@
|
||||||
"audio_embed_deleted" = "Аудиозапись была удалена";
|
"audio_embed_deleted" = "Аудиозапись была удалена";
|
||||||
"audio_embed_withdrawn" = "Аудиозапись была изъята по обращению правообладателя.";
|
"audio_embed_withdrawn" = "Аудиозапись была изъята по обращению правообладателя.";
|
||||||
"audio_embed_forbidden" = "Настройки приватности пользователя не позволяют встраивать эту композицию";
|
"audio_embed_forbidden" = "Настройки приватности пользователя не позволяют встраивать эту композицию";
|
||||||
"audio_embed_processing" = "Аудио ещё обрабатывается, либо обработалось неправильно.";
|
"audio_embed_processing" = "Аудио находится в обработке.";
|
||||||
|
"audio_embed_processing_bait" = "Всё равно хочу воспроизвести";
|
||||||
|
|
||||||
"audios_count_zero" = "Нет аудиозаписей";
|
"audios_count_zero" = "Нет аудиозаписей";
|
||||||
"audios_count_one" = "Одна аудиозапись"; /* сингл */
|
"audios_count_one" = "Одна аудиозапись"; /* сингл */
|
||||||
|
@ -994,6 +995,12 @@
|
||||||
"audio_ctx_play_next" = "Воспроизвести следующим";
|
"audio_ctx_play_next" = "Воспроизвести следующим";
|
||||||
"audio_ctx_clear_context" = "Очистить список треков";
|
"audio_ctx_clear_context" = "Очистить список треков";
|
||||||
|
|
||||||
|
"is_x_audio_zero" = "Нету аудиозаписей";
|
||||||
|
"is_x_audio_one" = "Всего одна аудиозапись.";
|
||||||
|
"is_x_audio_few" = "Всего $1 аудиозаписи.";
|
||||||
|
"is_x_audio_many" = "Всего $1 аудиозаписей.";
|
||||||
|
"is_x_audio_other" = "Всего $1 аудиозаписей.";
|
||||||
|
|
||||||
/* Notifications */
|
/* Notifications */
|
||||||
|
|
||||||
"feedback" = "Ответы";
|
"feedback" = "Ответы";
|
||||||
|
|
Loading…
Reference in a new issue