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