mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
add time to now playing card
This commit is contained in:
+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