added first functions
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Artem Anufrij 2023-09-19 01:56:09 +02:00
parent 8248073a4d
commit 239b538c4b
4 changed files with 100 additions and 55 deletions

View File

@ -1,5 +1,5 @@
{
"backend_de": "http://localhost:31204",
"backend_dev": "https://webplay.rocks",
"backend_dev": "http://localhost:31204",
"backend_de": "https://webplay.rocks",
"backend": "https://webplay.rocks"
}

View File

@ -48,7 +48,7 @@ export default {
duration: 0,
progress: 0,
intervalProgress: 0,
intervalHistory: 0,
intervalState: 0,
preConvert: false,
};
},
@ -68,25 +68,27 @@ export default {
this.audio.pause();
window.clearInterval(this.intervalProgress);
window.clearInterval(this.intervalHistory);
window.clearInterval(this.intervalState);
this.progress = this.audio.currentTime;
this.pushState();
},
durationChanged() {
this.duration = this.audio.duration;
},
playing() {
window.clearInterval(this.intervalProgress);
window.clearInterval(this.intervalHistory);
window.clearInterval(this.intervalState);
this.intervalProgress = setInterval(() => {
this.progress = this.audio.currentTime;
this.selectedTrack.percent = (100 / this.duration) * this.progress;
}, 500);
this.intervalHistory = setInterval(() => {
console.log(this.selectedTrack);
if (this.currentUser._id) {
this.intervalState = setInterval(() => {
this.pushState();
}, 10000);
}
},
audioReset() {
this.audio.pause();
@ -107,6 +109,14 @@ export default {
this.audio.play();
}
},
skipToSecond(second) {
let was_paused = this.audio.paused;
this.audio.pause();
this.audio.currentTime = second;
if (!was_paused) {
this.audio.play();
}
},
playRadio(radio) {
this.$store.commit("tracks/resetSelectedTrack");
this.audio.pause();
@ -135,8 +145,12 @@ export default {
this.pushHistoryItem();
if (this.selectedTrack.parent.progress) {
this.skipToSecond(this.selectedTrack.parent.progress.progress);
} else {
// Try to fix SAFARI
this.audio.play();
}
},
pushHistoryItem() {
if (!this.currentUser._id) {
@ -190,7 +204,7 @@ export default {
},
reset() {
window.clearInterval(this.intervalProgress);
window.clearInterval(this.intervalHistory);
window.clearInterval(this.intervalState);
if (!this.audio.paused) {
this.audio.pause();
}
@ -251,6 +265,19 @@ export default {
}
this.$store.dispatch("user/savePlayerSettings");
},
pushState() {
if (!this.currentUser._id) {
return;
}
this.progress = this.audio.currentTime;
let item = {
id: this.selectedTrack._id,
parentId: this.selectedTrack.parent._id,
type: "track",
progress: Math.round(this.progress)
}
this.$store.dispatch("user/saveProgress", item);
},
timeUpdate(event) {
let percent = (event.target.currentTime / event.target.duration) * 100;
if (percent > 10 && !this.preConvert) {

View File

@ -1,25 +1,12 @@
<template>
<DialogBase
ref="dialogWindow"
:title="album_title"
@canceled="closed"
:showFooter="false"
:disableXscroll="true"
:disableYscroll="true"
>
<DialogBase ref="dialogWindow" :title="album_title" @canceled="closed" :showFooter="false" :disableXscroll="true" :disableYscroll="true">
<div id="albumViewer" class="flex-row">
<div id="header" class="flex-column">
<div id="background" :style="coverBackground" />
<div class="grow z1 center flex-column">
<img class="glow ma24" :src="cover" @dblclick="dblclick" />
</div>
<awesome-icon
icon="star"
size="2x"
class="favourite ma4"
:class="{ active: isFavourite }"
@click="toggleFavourite"
/>
<awesome-icon icon="star" size="2x" class="favourite ma4" :class="{ active: isFavourite }" @click="toggleFavourite" />
<div id="stats" class="flex-row z1">
<DropDown v-if="$store.getters['user/isAdministrator']">
<button class="flat center" :title="visibility_text">
@ -27,11 +14,7 @@
</button>
<template v-slot:dropdown-content>
<div>
<button
v-for="(item, i) in $store.state.system.lists.visibility"
:key="i"
@click="setVisibility(item)"
>
<button v-for="(item, i) in $store.state.system.lists.visibility" :key="i" @click="setVisibility(item)">
<awesome-icon :icon="getVisibilityIcon(item)" />{{
getVisibilityText(item)
}}
@ -40,10 +23,7 @@
<button v-if="!selectedAlbum.share._id" @click="shareEnable">
<awesome-icon icon="share" />Share this album
</button>
<button
v-if="selectedAlbum.share._id"
@click="addShareUrlToClipboard"
>
<button v-if="selectedAlbum.share._id" @click="addShareUrlToClipboard">
<awesome-icon icon="clipboard" />Copy url into clipboard
</button>
<button v-if="selectedAlbum.share._id" @click="shareDisable">
@ -61,8 +41,7 @@
}}</b>
<br />
<span v-if="album_year">
from year <b>{{ album_year }}</b> </span
><br />
from year <b>{{ album_year }}</b> </span><br />
<b>{{ album_tracks.length }}</b> Tracks with a duration of
<b>{{ album_duration }}</b>
</span>
@ -89,6 +68,7 @@
</DropDown>
</div>
</div>
<p v-if="selectedAlbum.progress" @click="playProgress">Progress</p>
<ul id="trackList" class="tracks">
<li v-for="track in selectedAlbum.tracks" :key="track._id">
@ -156,6 +136,14 @@ export default {
}
}
},
playProgress() {
let track = this.selectedAlbum.tracks.find(
(f) => f._id == this.selectedAlbum.progress.id
);
if (track) {
this.$store.dispatch("tracks/play", track);
}
},
closed() {
if (
(window.history.state.back &&
@ -228,6 +216,9 @@ export default {
shareDisable() {
this.$store.dispatch("albums/shareDisable", this.selectedAlbum);
},
loadUserProgress() {
this.$store.dispatch("user/getProgress", this.selectedAlbum);
}
},
computed: {
...mapGetters({
@ -318,6 +309,7 @@ export default {
this.$refs.dialogWindow.open();
window.addEventListener("keydown", this.keydownListener);
}
this.loadUserProgress();
this.gotoTrack();
} else {
if (this.$refs.dialogWindow.visible) {
@ -339,14 +331,17 @@ export default {
height: 366px;
width: 640px;
}
#header {
position: relative;
background-color: black;
}
#header img {
align-self: center;
width: 256px;
}
#stats {
z-index: 2;
align-items: center;
@ -357,10 +352,12 @@ export default {
border-top: 1px solid #ffffff20;
border-bottom: 1px solid #00000020;
}
.dropdown-activator button {
width: 32px;
height: 32px;
}
#trackList {
background-color: var(--white);
z-index: 1;
@ -370,15 +367,19 @@ export default {
#header {
width: 100%;
}
#albumViewer {
flex-direction: column;
}
}
@media (max-width: 480px), (max-height: 480px) {
@media (max-width: 480px),
(max-height: 480px) {
#albumViewer {
width: 100%;
height: 100%;
}
#trackList {
height: initial;
flex-grow: 1;

View File

@ -80,6 +80,23 @@ export default {
context.commit("setHistory", res.data);
});
},
saveProgress(context, item) {
if (context.state._id == -1) {
return;
}
axios.post(context.rootGetters.server + "/api/user/progress", item, context.rootGetters.headers);
},
getProgress(context, parent) {
if (context.state._id == -1) {
return;
}
axios
.get(context.rootGetters.server + "/api/user/progress/" + parent._id, context.rootGetters.headers)
.then((res) => {
parent.progress = res.data;
});
},
savePlayerSettings(context) {
let body = {
repeat: context.rootGetters["player/repeatType"],