mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
add time to now playing card
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<div class="hotkeys">
|
<div class="hotkeys">
|
||||||
<div class="image ctrl-btn" id="previous" @click="q.playPrev"></div>
|
<div class="image ctrl-btn" id="previous" @click="q.playPrev"></div>
|
||||||
<div
|
<div
|
||||||
@@ -17,6 +18,7 @@ const q = useQStore();
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
||||||
.hotkeys {
|
.hotkeys {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<input
|
<input
|
||||||
id="progress"
|
id="progress"
|
||||||
type="range"
|
type="range"
|
||||||
:value="q.track.current_time"
|
:value="q.duration.current"
|
||||||
min="0"
|
min="0"
|
||||||
max="100"
|
:max="q.duration.full"
|
||||||
step="0.1"
|
step="0.1"
|
||||||
@change="seek()"
|
@change="seek()"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="r-now-playing t-center rounded">
|
<div class="now-playing-card t-center rounded">
|
||||||
<div class="headin">Now Playing</div>
|
<div class="headin">Now Playing</div>
|
||||||
<div
|
<div
|
||||||
class="button menu rounded"
|
class="button menu rounded"
|
||||||
@@ -11,6 +11,10 @@
|
|||||||
<div class="separator no-border"></div>
|
<div class="separator no-border"></div>
|
||||||
<div>
|
<div>
|
||||||
<SongCard :track="queue.tracks[queue.current]" />
|
<SongCard :track="queue.tracks[queue.current]" />
|
||||||
|
<div class="l-track-time">
|
||||||
|
<span class="rounded">{{ formatSeconds(queue.duration.current) }}</span
|
||||||
|
><span class="rounded">{{ formatSeconds(queue.duration.full) }}</span>
|
||||||
|
</div>
|
||||||
<Progress />
|
<Progress />
|
||||||
<HotKeys />
|
<HotKeys />
|
||||||
</div>
|
</div>
|
||||||
@@ -18,16 +22,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import SongCard from "./SongCard.vue";
|
import { ContextSrc } from "@/composables/enums";
|
||||||
import HotKeys from "./NP/HotKeys.vue";
|
|
||||||
import Progress from "./NP/Progress.vue";
|
|
||||||
import useQStore from "../../stores/queue";
|
|
||||||
import MenuSvg from "../../assets/icons/more.svg";
|
|
||||||
import trackContext from "@/contexts/track_context";
|
import trackContext from "@/contexts/track_context";
|
||||||
import useContextStore from "@/stores/context";
|
import useContextStore from "@/stores/context";
|
||||||
import useModalStore from "@/stores/modal";
|
import useModalStore from "@/stores/modal";
|
||||||
import useQueueStore from "@/stores/queue";
|
import useQueueStore from "@/stores/queue";
|
||||||
import { ContextSrc } from "@/composables/enums";
|
import MenuSvg from "../../assets/icons/more.svg";
|
||||||
|
import useQStore from "../../stores/queue";
|
||||||
|
import HotKeys from "./NP/HotKeys.vue";
|
||||||
|
import Progress from "./NP/Progress.vue";
|
||||||
|
import SongCard from "./SongCard.vue";
|
||||||
|
import { formatSeconds } from "@/composables/perks";
|
||||||
|
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
@@ -56,7 +61,7 @@ const showContextMenu = (e: Event) => {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.r-now-playing {
|
.now-playing-card {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
background-color: $primary;
|
background-color: $primary;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -64,6 +69,17 @@ const showContextMenu = (e: Event) => {
|
|||||||
position: relative;
|
position: relative;
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
|
|
||||||
|
.l-track-time {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
span {
|
||||||
|
font-size: small;
|
||||||
|
// background-color: $gray;
|
||||||
|
padding: $smaller;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
::-moz-range-thumb {
|
::-moz-range-thumb {
|
||||||
height: 0.8rem;
|
height: 0.8rem;
|
||||||
|
|||||||
+11
-7
@@ -52,9 +52,9 @@ export default defineStore("Queue", {
|
|||||||
state: () => ({
|
state: () => ({
|
||||||
progressElem: HTMLElement,
|
progressElem: HTMLElement,
|
||||||
audio: new Audio(),
|
audio: new Audio(),
|
||||||
track: {
|
duration: {
|
||||||
current_time: 0,
|
current: 0,
|
||||||
duration: 0,
|
full: 0,
|
||||||
},
|
},
|
||||||
current: 0,
|
current: 0,
|
||||||
next: 0,
|
next: 0,
|
||||||
@@ -80,15 +80,16 @@ export default defineStore("Queue", {
|
|||||||
this.audio.onerror = reject;
|
this.audio.onerror = reject;
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.track.duration = this.audio.duration;
|
this.duration.full = this.audio.duration;
|
||||||
this.audio.play().then(() => {
|
this.audio.play().then(() => {
|
||||||
this.playing = true;
|
this.playing = true;
|
||||||
notif(track, this.playPause, this.playNext, this.playPrev);
|
notif(track, this.playPause, this.playNext, this.playPrev);
|
||||||
|
|
||||||
this.audio.ontimeupdate = () => {
|
this.audio.ontimeupdate = () => {
|
||||||
this.track.current_time =
|
this.duration.current = this.audio.currentTime;
|
||||||
|
const bg_size =
|
||||||
(this.audio.currentTime / this.audio.duration) * 100;
|
(this.audio.currentTime / this.audio.duration) * 100;
|
||||||
elem.style.backgroundSize = `${this.track.current_time}% 100%`;
|
elem.style.backgroundSize = `${bg_size}% 100%`;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.audio.onended = () => {
|
this.audio.onended = () => {
|
||||||
@@ -162,8 +163,11 @@ export default defineStore("Queue", {
|
|||||||
this.prev = index - 1;
|
this.prev = index - 1;
|
||||||
},
|
},
|
||||||
setCurrent(index: number) {
|
setCurrent(index: number) {
|
||||||
|
const track = this.tracks[index];
|
||||||
|
|
||||||
this.current = index;
|
this.current = index;
|
||||||
this.currentid = this.tracks[index].trackid;
|
this.currentid = track.trackid;
|
||||||
|
this.duration.full = track.length;
|
||||||
},
|
},
|
||||||
setNewQueue(tracklist: Track[]) {
|
setNewQueue(tracklist: Track[]) {
|
||||||
if (this.tracks !== tracklist) {
|
if (this.tracks !== tracklist) {
|
||||||
|
|||||||
Reference in New Issue
Block a user